I have a Spring Boot properties with three properties files:
I have a class that uses values defined in application-local.properties file, which I thought would get used because application-properties has `spring.profiles.active=local
When I start up in IntelliJ, I see this in the console logs:
Loaded config file 'file:.../build/resources/main/application.properties' (classpath:/application.properties)
2016-12-18 20:10:17.596 DEBUG 29999 --- [ restartedMain] o.s.b.c.c.ConfigFileApplicationListener : Loaded config file 'file:.../build/resources/main/application-local.properties' (classpath:/application-local.properties)`
Skipped (empty) config file 'file:...build/resources/main/application-local.properties' (classpath:/application-local.properties) for profile local
It says it skipped the empty config file, but when I inspect 'build/resources/main/application-local.properties' then I see the values in there.
However, the following class does not have the properties when I run it from within IntelliJ as a Spring Boot Application. It throws a null pointer because these are null:
@Value("${myapp.ApiKey}")
private String apiKey;
@Value("${myapp.ApiSecret}")
private String apiSecret;
@Value("${myapp.user}")
private String user;
In the Application Configuration I tried using Active Profiles, Program Arguments, and Environment Variables.
However, if I run from the command line as:
java -jar -Dspring.active.profiles=local build/libs/myjar-0.0.1-SNAPSHOT.jar
then it works just fine. I am sure this was working previously, but not sure if the IntelliJ version was the same. Any tips on how to make the correct version of my application.properties get used?