This Java project connects to a MySQL database and can be extended to explore bird migration patterns — potentially using real-world data from sources like eBird.
- Java Development Kit (JDK) installed and on your PATH
- MySQL installed and running locally
- MySQL Workbench (optional GUI)
- Maven installed and configured
- Bash (WSL or Linux terminal)
bird-migration/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/craig/birdmigration/
│ │ │ └── BirdMigrationApp.java # Main Java source file
│ │ └── resources/
│ │ └── db.properties # Database credentials (not versioned)
├── target/ # Compiled classes and packaged JARs (auto-generated)
├── pom.xml # Maven project file
└── run.sh # Optional script to run Maven commands
-
Create the database in MySQL:
CREATE DATABASE bird_migration; USE bird_migration;
-
Configure your database credentials:
Create
src/main/resources/db.properties(add to.gitignore):db.url=jdbc:mysql://localhost:3306/bird_migration db.user=root db.password=your_password_here
-
(Recommended) Use environment variables for secrets
Instead of hardcoding credentials, export environment variables in your terminal or OS profile:
export DB_USER=root export DB_PASSWORD=your_password_here export EBIRD_API_TOKEN=your_ebird_api_key_here
These can be referenced in
application.propertiesor your Java code as${DB_USER},${DB_PASSWORD}, and${EBIRD_API_TOKEN}. This approach keeps your secrets out of the codebase. -
Build the project with Maven:
mvn compile
-
Run the project:
mvn spring-boot:run
(Make sure you have the
spring-boot-maven-pluginconfigured in yourpom.xml.)
- Connects to local MySQL using Maven dependencies
- Reads credentials from
db.propertiesor environment variables - REST API exposes endpoints to:
- Fetch birds from the database
- Query eBird API for real-time bird data if not in local DB (e.g.,
/api/ebird/bird/{name})
- Saves eBird API results into the local database for caching
- Base URL:
https://api.ebird.org/v2/ - Example endpoint to get recent observations for a region:
GET /data/obs/{regionCode}/recent - Authentication:
Include your API token in the header for all requests: