Spring Boot Profile-Specific Properties to JSON
Convert Spring Boot profile-specific application-{profile}.properties files into JSON for environment-based configuration management.
Detailed Explanation
Profile-Specific Properties
Spring Boot supports environment-specific configuration through profile-based properties files. Common profiles include application-dev.properties, application-staging.properties, and application-prod.properties.
Example: Development Profile
# application-dev.properties
spring.profiles.active=dev
spring.datasource.url=jdbc:h2:mem:devdb
spring.datasource.driver-class-name=org.h2.Driver
spring.h2.console.enabled=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.show-sql=true
logging.level.root=DEBUG
logging.level.org.springframework.web=TRACE
server.port=8081
Example: Production Profile
# application-prod.properties
spring.profiles.active=prod
spring.datasource.url=jdbc:postgresql://db.prod.internal:5432/proddb
spring.datasource.username=${DB_USERNAME}
spring.datasource.password=${DB_PASSWORD}
spring.datasource.hikari.maximum-pool-size=20
spring.datasource.hikari.minimum-idle=5
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.show-sql=false
logging.level.root=WARN
server.port=80
JSON Comparison
Converting both profiles to JSON makes it easy to diff them side-by-side, revealing the exact differences between environments. This is especially useful for auditing production configuration or onboarding new team members who need to understand environment-specific settings.
Handling Variable Placeholders
Properties files often contain Spring Expression Language placeholders like ${DB_USERNAME}. These are preserved as-is in the JSON output since they represent runtime-resolved values, not static strings.
Use Case
Comparing configuration across Spring Boot environments (dev/staging/prod) by converting each profile's properties file to JSON and using a diff tool, or exporting to a centralized configuration store.