Spring Boot adding another properties file to environment
I was wondering if it is possible to add another properties file to the environment path besides the application.properties file. If so, how do you specify the new path? This way you can access the properties using the Autwired Environment variable. Currently in my java project the default properties file application.properties is / soctrav / src.main.resources / application.properties
+3
starcraftOnCrack
source
to share
2 answers
You can specify additional properties files with command line parameters:
java -jar myproject.jar --spring.config.location=classpath:/default.properties,classpath:/override.properties
Take a look at the Spring Application Properties file in the Boot Documentation section .
+2
luboskrnac
source
to share
If you want to do it without command line parameters, this will do the trick.
@SpringBootApplication
@PropertySources({
@PropertySource("classpath:application.properties"),
@PropertySource("classpath:anotherbunchof.properties")
})
public class YourApplication{
}
+2
jayb0b
source
to share