Skip to main content
This guide covers all configuration options for the DriveX Backend API, including database connections, server settings, and JPA configuration.

Application Properties

The main configuration file is located at src/main/resources/application.properties. All settings can be overridden using environment variables.

Application Name

spring.application.name=DriveX-backend
Defines the application name used in Spring Boot’s internal configuration and logging.

Database Configuration

1

Configure Database Connection

Set up your MySQL database connection parameters:
spring.datasource.url=jdbc:mysql://localhost:3306/railway
spring.datasource.username=root
spring.datasource.password=your_password_here
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
Never commit sensitive credentials to version control. Use environment variables for production deployments.
2

Configure JPA/Hibernate Settings

The application uses Spring Data JPA with Hibernate as the ORM provider:
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
The ddl-auto=update setting automatically updates the database schema based on your entity classes. Consider using validate in production environments.

Server Configuration

Port and Context Path

Configure the server port and base API path:
server.servlet.context-path=/api
server.port=${PORT:8080}
server.address=0.0.0.0
PropertyDefaultDescription
server.port8080HTTP port the server listens on. Reads from PORT environment variable if available
server.servlet.context-path/apiBase path for all API endpoints
server.address0.0.0.0Network interface to bind to. 0.0.0.0 allows external access
All API endpoints will be prefixed with /api. For example, the vehicles endpoint will be accessible at /api/vehicles.

Configuration Options Reference

Database Properties

spring.datasource.url=jdbc:mysql://localhost:3306/railway
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect

JPA/Hibernate Properties

PropertyValueDescription
spring.jpa.hibernate.ddl-autoupdateSchema generation strategy. Options: create, create-drop, update, validate, none
spring.jpa.show-sqltrueLog SQL statements to console
spring.jpa.properties.hibernate.format_sqltrueFormat logged SQL for readability
spring.jpa.database-platformorg.hibernate.dialect.MySQLDialectHibernate dialect for MySQL optimization

Environment-Specific Configuration

Development

spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
Development mode enables SQL logging and automatic schema updates for faster iteration.

Production

spring.jpa.hibernate.ddl-auto=validate
spring.jpa.show-sql=false
spring.jpa.properties.hibernate.format_sql=false
In production:
  • Use validate to prevent automatic schema changes
  • Disable SQL logging for better performance
  • Use environment variables for all sensitive configuration
  • Consider using Spring Profiles for environment-specific configs

Using Environment Variables

All Spring Boot properties can be overridden with environment variables by converting the property name:
  1. Convert to uppercase
  2. Replace dots (.) with underscores (_)
  3. Replace hyphens (-) with underscores (_)
Examples:
PropertyEnvironment Variable
spring.datasource.urlSPRING_DATASOURCE_URL
spring.datasource.usernameSPRING_DATASOURCE_USERNAME
server.portSERVER_PORT
spring.jpa.show-sqlSPRING_JPA_SHOW_SQL

Docker Example

docker run -p 8080:8080 \
  -e SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/railway \
  -e SPRING_DATASOURCE_USERNAME=root \
  -e SPRING_DATASOURCE_PASSWORD=secret \
  -e PORT=8080 \
  drivex-backend:latest

Dependencies

The following key dependencies are configured in pom.xml:
  • Spring Boot 4.0.0 - Application framework
  • Spring Data JPA - Database access and ORM
  • MySQL Connector/J - MySQL JDBC driver
  • Spring Security Crypto - Password hashing
  • Lombok 1.18.42 - Boilerplate reduction
  • Spring Boot DevTools - Development utilities

Next Steps

Database Setup

Learn how to set up and configure the DriveX database schema

Deployment

Deploy the DriveX Backend API to production

Build docs developers (and LLMs) love