Step 1: Configure Development and Production Profiles in Spring Boot
AWS Lightsail Deployment Course
2026-04-08
Configure Development and Production Profiles in Spring Boot
Preparing your Spring Boot application for seamless deployment to AWS Lightsail
Why Spring Boot Profiles Matter
Development Environment
Local database connections
Debug logging enabled
Development-friendly settings
Production Environment
Cloud database connections
Optimized performance settings
Security-focused configuration
Base Configuration Setup
Create application.properties with common settings:
# Application name and basic settingsspring.application.name=my-spring-appserver.servlet.context-path=/# Default active profilespring.profiles.active=dev# JPA/Hibernate common settingsspring.jpa.hibernate.ddl-auto=updatespring.jpa.show-sql=false
Development Profile Configuration
Create application-dev.properties:
# Local MySQL database configurationspring.datasource.url=jdbc:mysql://localhost:3306/myapp_devspring.datasource.username=dev_userspring.datasource.password=dev_password# Development-specific settingsspring.jpa.show-sql=truelogging.level.org.springframework.web=DEBUGserver.port=8080
Production Profile Configuration
Create application-prod.properties:
# Production database with environment variablesspring.datasource.url=${DB_URL:jdbc:mysql://localhost:3306/myapp_prod}spring.datasource.username=${DB_USERNAME:prod_user}spring.datasource.password=${DB_PASSWORD:secure_password}# Production optimizationsspring.jpa.show-sql=falsespring.jpa.hibernate.ddl-auto=validateserver.compression.enabled=true
# Run with development profile (default)mvn spring-boot:run# Or explicitly specifymvn spring-boot:run -Dspring-boot.run.profiles=dev
Production Profile Testing
# Set environment variablesexportDB_URL="jdbc:mysql://localhost:3306/myapp_test"exportDB_USERNAME="test_user"# Run with production profilemvn spring-boot:run -Dspring-boot.run.profiles=prod
Building for Production
Create deployment-ready JAR:
# Clean and build the projectmvn clean package# Verify the JAR was createdls-la target/*.jar
Output:
-rw-r--r-- 1 user user 45M Dec 1 10:30 my-spring-app-1.0.0.jar
Configuration Verification Checklist
✓ Created application.properties, application-dev.properties, and application-prod.properties
✓ Application starts successfully with development profile
✓ Executable JAR builds without errors
✓ Database dependencies configured in build file
✓ Environment variable syntax working in production profile
Key Benefits Achieved
Development Benefits
Local development database
Debug logging enabled
Fast development cycle
Easy configuration changes
Production Benefits
Secure credential management
Optimized performance settings
Environment-specific configurations
Cloud-ready deployment package
What’s Next?
Coming Up in Step 2:
Create AWS Lightsail instance
Configure Linux environment
Set up MySQL database
Prepare for application deployment
Your Spring Boot application is now production-ready with proper profile configuration!
Summary
Spring Boot profiles enable environment-specific configurations
Environment variables provide secure credential management
Executable JARs simplify deployment processes
Proper configuration is essential for cloud deployments
Your application is now ready for AWS Lightsail deployment!