Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Profile specific application properties not picked by Spring Boot 3 native executable

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?

like image 345
Ladu anand Avatar asked Jul 14 '26 16:07

Ladu anand


1 Answers

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.

like image 186
Ladu anand Avatar answered Jul 17 '26 18:07

Ladu anand



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!