First of all, you don’t need to use a profile. The resources db.properties
is a test resource so it should be located under src/test/resources
and not under src/main/resources
. Using profiles will complicate your build, you should only resort to them as a last condition.
The reason you’re having this problem is that Spring Boot redefines the token filter to be @
instead of the default ${*}
. From the docs:
If you are inheriting from the
spring-boot-starter-parent
POM, the default filter token of themaven-resources-plugins
has been changed from${*}
to@
(i.e.@maven.token@
instead of${maven.token}
) to prevent conflicts with Spring-style placeholders. If you have enabled maven filtering for theapplication.properties
directly, you may want to also change the default filter token to use other delimiters.
This means that you should have instead:
jdbc.url= @db.jdbcUrl@
jdbc.username= @db.jdbcUn@
jdbc.password= @db.jdbcPw@
for the db.properties
file.
Then you need to remove your <resources>
section and replace it with:
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
<includes>
<include>db.properties</include>
</includes>
</testResource>
</testResources>