Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot Application java -jar --property override not working

I've written a Spring Boot Application. I'm running the jar, while running the jar I'm overriding the property file keys for e.g: java -jar example.jar --spring.profiles.active=test, but the key is not overriding. What could be the reason for this?

like image 819
Kiba Avatar asked Jun 30 '26 12:06

Kiba


1 Answers

For command line arguments to override properties, you need to pass the arguments from your application's main method into SpringApplication.run.

Your main method should look something like this:

public static void main(String[] args) throws Exception {
    SpringApplication.run(YourApplication.class, args);
}
like image 160
Andy Wilkinson Avatar answered Jul 03 '26 02:07

Andy Wilkinson



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!