Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring boot properties file override from command line

I am having problem with Spring Boot and fat jar invocation from command line.I am trying to overide property from command line but without success.
I have parameter in the code:

@Value("${param1}")
private String param1;

and also I have put application.properties file inside src\main\resources with following content;

param1=Param 1 value from properties file

When I build jar and run with:

java -jar java-apns-notifier-0.1.0.jar --param1=Aaaaaaaaa

param1 is printed with value from application.properties file and not takes into account value from command line.
Project source code is here

Any idea?

like image 678
gandra404 Avatar asked Dec 20 '22 01:12

gandra404


1 Answers

You forgot to pass the arguments in your Application class. You just need to change

SpringApplication.run(Application.class);

to

SpringApplication.run(Application.class, args);
like image 106
Paulo Santos Avatar answered Dec 21 '22 13:12

Paulo Santos