Reputation: 539
I have a project that uses Spring Boot. I need to rename the application.properties file to something else (i.e. othername.properties). The reason I need to rename it is because we have a bunch of other scripts that rely on that naming convention.
How can I tell Spring Boot to use othername.properties instead of the default application.properties? The documentation says that I can use the java command and pass an argument when running the application, but that doesn't help when I run a maven > install because there are spring integration/unit tests to be run as well (which rely on the application.properties file db settings).
Right now I have tried to set an environment property in the maven-surefire plugin like so:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<spring.config.name>othername.properties</spring.config.name>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</pluginManagement>
When I add that in my pom.xml, it seems that Spring Boot isn't picking up that file, and also isn't reading from application.properties (because the db settings are in application.properties as well as othername.properties right now, and it fails, so I know it isn't being read).
The otherfile.properties is in my project's resources folder, should it go somewhere else? Also, how do I specify a relative path to that file if it were to live somewhere else?
Upvotes: 1
Views: 2559
Reputation: 941
Didn't try it, but I think it should be
<systemPropertyVariables> <spring.config.name>othername</spring.config.name> </systemPropertyVariables>
Without .properties
Upvotes: 1