Download the external configuration - this is what you are looking for.
He especially mentions:
SpringApplication will load the properties from the application.properties files in the following places and add them to the Spring Environment:
- A / config subdirectory of the current directory.
- Current directory
- Classpath / config package
- Classpath root
So, I would add that adding a config folder to the class path is a good step. He should find application.properties and download it automatically.
For different configuration files, I use:
@Configuration @EnableAutoConfiguration @PropertySource({ "classpath:path/some.properties", "classpath:another/path/xmlProperties.xml" }) public class MyConfiguration {
Edit: As Dave noted (Thank Dave!), There is either -cp or -jar, so you cannot add it to the classpath. But there are options. This should help you solve the problem: Call & java -jar MyFile.jar "with the optional classpath option .
In addition, @PropertySource does not require that resources be classpath resources, if I am not mistaken.
source share