Reputation: 650
I am planning to use a native image with Spring Boot 3. My environment-specific properties are stored in the application.properties file. Sample file
spring.config.activate.on-profile=dev
server.port=9092
#---
spring.config.activate.on-profile=local
server.port=9093
I build the native executable using the following command
./mvnw -Pnative native:compile -Dspring.profiles.active=local
and run the executable using the below command
./target/<app-executable> -Dspring.profiles.active=local
In the logs I see
No active profile set, falling back to 1 default profile: "default"
Am I doing something wrong or Are profiles not supported with Spring Boot 3 native image?
Upvotes: 3
Views: 2338
Reputation: 650
Able to make it work by passing the arguments as -- instead of using -D.
For building the native image, no need to pass -D.
./mvnw -Pnative native:compile
And to run the executable with system properties, use the below command
./target/<app-executable> --spring.profiles.active=local
This picked up the server.port=9093.
Upvotes: 4