Prerequisites
Before you begin, ensure you have the following installed:- Java 17 or higher (Download OpenJDK)
- Maven 3.9+ (Download Maven)
- MySQL database server running locally or accessible remotely
- Git for cloning the repository
If you prefer using Docker, skip to the Docker Setup section for a containerized deployment.
Quick Setup
Configure Database Connection
Create or edit the
src/main/resources/application.properties file with your MySQL credentials:Install Dependencies
Use Maven to download all required dependencies:This command will:
- Clean any previous build artifacts
- Download all dependencies defined in
pom.xml - Compile the project
- Run tests (if any)
- Package the application
Run the Application
Start the Spring Boot application using Maven:Or run the JAR file directly:You should see output indicating the server is running:
Verify the API is Running
Test the API with a simple GET request to list all vehicles:You should receive a JSON response (empty array if no vehicles exist yet):
Docker Setup
For a containerized deployment, use the included Dockerfile:Build the Docker Image
Build the multi-stage Docker image:This uses the production-ready Dockerfile that:
- Builds the JAR using Maven in stage 1
- Creates a lightweight runtime image with Eclipse Temurin JDK 17
Run the Container
Run the container with environment variables:
Use
host.docker.internal to connect to MySQL running on your host machine from within the container.Development Mode
For active development with hot reload, the project includes Spring Boot DevTools:- Java classes
- Property files
- Static resources
DevTools is only active when running the application from the classpath (via
mvn spring-boot:run), not when running a packaged JAR.Testing the API
Here are some common API endpoints to test:Next Steps
Installation Guide
Detailed setup for production environments
API Reference
Complete API endpoint documentation
Troubleshooting
Port 8080 already in use
Port 8080 already in use
Change the port in Or set the PORT environment variable:
application.properties:Cannot connect to MySQL
Cannot connect to MySQL
Verify:
- MySQL server is running:
mysql -u root -p - Database exists:
SHOW DATABASES; - User has permissions:
GRANT ALL PRIVILEGES ON drivex.* TO 'your_username'@'localhost'; - Connection URL is correct in
application.properties
Maven build fails
Maven build fails
Clear Maven cache and rebuild:Ensure Java 17 is installed:
404 on all endpoints
404 on all endpoints
Remember that all endpoints are prefixed with Not:
/api due to the context path configuration. Use: