The Furniture API uses Spring Boot configuration properties that can be customized through environment variables. This guide covers all available configuration options.
Application Properties
Core Configuration
The application uses the following core settings defined in application.properties:
spring.application.name =microservice-rest
server.port =8082
The application name is used for service registration with Eureka and logging. The server runs on port 8082 by default.
Database Configuration
Connection Settings
Configure PostgreSQL database connection:
application.properties
Environment Variables
Docker Compose
spring.datasource.url =jdbc:postgresql://localhost:5432/catalog_and_inventory_db
spring.jpa.database-platform =org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto =none
spring.jpa.hibernate.naming.physical-strategy =org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
JPA and Hibernate Properties
# Disable Open Session in View
spring.jpa.open-in-view =false
# Hibernate DDL auto (none, validate, update, create, create-drop)
spring.jpa.hibernate.ddl-auto =none
# Naming strategy
spring.jpa.hibernate.naming.physical-strategy =org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
Never use spring.jpa.hibernate.ddl-auto=create or create-drop in production. These settings will drop your database tables.
Jackson Configuration
JSON Serialization
The application uses custom Jackson settings:
spring.jackson.serialization.fail-on-empty-beans =false
spring.jackson.property-naming-strategy =SNAKE_CASE
The SNAKE_CASE strategy converts Java camelCase field names to snake_case in JSON responses (e.g., furnitureItem becomes furniture_item).
Available Naming Strategies
LOWER_CAMEL_CASE - Default Java convention (e.g., furnitureItem)
UPPER_CAMEL_CASE - Pascal case (e.g., FurnitureItem)
SNAKE_CASE - Underscore separated (e.g., furniture_item)
LOWER_CASE - All lowercase (e.g., furnitureitem)
KEBAB_CASE - Hyphen separated (e.g., furniture-item)
Thymeleaf Configuration
spring.thymeleaf.check-template-location =false
Template location checking is disabled since the API primarily serves JSON responses. Enable this if you’re using Thymeleaf templates.
Swagger/OpenAPI Configuration
SpringDoc Settings
The API documentation is configured as follows:
springdoc.api-docs.enabled =true
springdoc.swagger-ui.enabled =true
springdoc.swagger-ui.path =/doc/swagger-ui.html
springdoc.packagesToScan =com.api.furniture
Enable API docs
API documentation is generated at runtime: springdoc.api-docs.enabled =true
Configure Swagger UI
Access the interactive API documentation: springdoc.swagger-ui.enabled =true
springdoc.swagger-ui.path =/doc/swagger-ui.html
Scan packages
Specify which packages to scan for API endpoints: springdoc.packagesToScan =com.api.furniture
Access Swagger UI at: http://localhost:8082/doc/swagger-ui.html
Eureka Service Discovery
Eureka Client Configuration
The application registers with Eureka for service discovery:
eureka.instance.prefer-ip-address =true
eureka.client.fetch-registry =true
eureka.client.register-with-eureka =true
eureka.client.service-url.defaultZone =https://furniture-eureka-server.onrender.com/eureka
application.properties
Environment Variables
eureka.instance.prefer-ip-address =true
eureka.client.fetch-registry =true
eureka.client.register-with-eureka =true
eureka.client.service-url.defaultZone =https://furniture-eureka-server.onrender.com/eureka
Eureka Configuration Options
Property Default Description eureka.instance.prefer-ip-addresstrueRegister using IP address instead of hostname eureka.client.fetch-registrytrueFetch service registry from Eureka server eureka.client.register-with-eurekatrueRegister this service with Eureka eureka.client.service-url.defaultZoneN/A Eureka server URL
If you’re not using Eureka, you can disable it by setting eureka.client.register-with-eureka=false.
Environment-Specific Configuration
Profile-Based Configuration
Create separate property files for different environments:
Create profile files
Create configuration files for each environment:
application-dev.properties
application-test.properties
application-prod.properties
Configure development
# application-dev.properties
server.port =8082
spring.datasource.url =jdbc:postgresql://localhost:5432/catalog_and_inventory_db
spring.jpa.hibernate.ddl-auto =update
spring.jpa.show-sql =true
spring.jpa.properties.hibernate.format_sql =true
eureka.client.register-with-eureka =false
Configure production
# application-prod.properties
server.port =8082
spring.datasource.url =${SPRING_DATASOURCE_URL}
spring.jpa.hibernate.ddl-auto =none
spring.jpa.show-sql =false
eureka.client.register-with-eureka =true
eureka.client.service-url.defaultZone =${EUREKA_SERVER_URL}
Activate profile
# Set active profile
export SPRING_PROFILES_ACTIVE = prod
# Or via command line
java -jar furniture-0.0.1-SNAPSHOT.jar --spring.profiles.active=prod
Complete Configuration Reference
All Environment Variables
Development
Production
Docker Compose
# Server
export SERVER_PORT = 8082
export SPRING_APPLICATION_NAME = microservice-rest
# Database
export SPRING_DATASOURCE_URL = jdbc : postgresql :// localhost : 5432 / catalog_and_inventory_db
export SPRING_JPA_DATABASE_PLATFORM = org . hibernate . dialect . PostgreSQLDialect
export SPRING_JPA_HIBERNATE_DDL_AUTO = update
export SPRING_JPA_SHOW_SQL = true
export SPRING_JPA_PROPERTIES_HIBERNATE_FORMAT_SQL = true
export SPRING_JPA_OPEN_IN_VIEW = false
# Jackson
export SPRING_JACKSON_SERIALIZATION_FAIL_ON_EMPTY_BEANS = false
export SPRING_JACKSON_PROPERTY_NAMING_STRATEGY = SNAKE_CASE
# Thymeleaf
export SPRING_THYMELEAF_CHECK_TEMPLATE_LOCATION = false
# Swagger/OpenAPI
export SPRINGDOC_API_DOCS_ENABLED = true
export SPRINGDOC_SWAGGER_UI_ENABLED = true
export SPRINGDOC_SWAGGER_UI_PATH = / doc / swagger-ui . html
export SPRINGDOC_PACKAGES_TO_SCAN = com . api . furniture
# Eureka (disabled for dev)
export EUREKA_CLIENT_REGISTER_WITH_EUREKA = false
Security Best Practices
Never commit sensitive values like passwords, API keys, or database credentials to version control.
Using .env Files
Create a .env file for local development:
# .env (add to .gitignore)
SPRING_DATASOURCE_URL = jdbc:postgresql://localhost:5432/catalog_and_inventory_db
SPRING_DATASOURCE_USERNAME = dev_user
SPRING_DATASOURCE_PASSWORD = dev_password
EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE = http://localhost:8761/eureka
Load with Docker Compose:
services :
server :
env_file :
- .env
Using Secrets Management
For production, use secret management services:
AWS Secrets Manager
HashiCorp Vault
Kubernetes Secrets
Docker Secrets
Validation and Testing
Verify Configuration
Check active configuration:
# View all properties
curl http://localhost:8082/actuator/env
# View specific property
curl http://localhost:8082/actuator/env/spring.datasource.url
Ensure Spring Boot Actuator is enabled and properly secured before exposing these endpoints.
Test Database Connection
Verify database connectivity:
curl http://localhost:8082/actuator/health
Expected response:
{
"status" : "UP" ,
"components" : {
"db" : {
"status" : "UP" ,
"details" : {
"database" : "PostgreSQL" ,
"validationQuery" : "isValid()"
}
}
}
}