So far I have found 2 methods to configure spring boot application at startup, one uses -D and the other one uses -- like this:
java -jar -Dspring.profiles.active=test app.jar
java -jar --spring.profiles.active=test app.jar
Sometimes, the first works, sometimes the second works. As a developer found, when run method in the following example is not given args parameter, -- method does not work, but -D does.
public static void main(final String[] args) {
SpringApplication.run(Application.class, args);
}
While today, I was configuring logback at command line, and found that -Dlogback.configurationFile=/full_path/logback.xml does not work but --logging.config=file:logback.xmldoes.
Above may have other reason, maybe logback.configurationFile is wrong, but it acts like -D and -- difference.
Then my question is what is -D and --, is it Java or Spring thing? why it varies between not working and working?