In my application I have three different profiles and their own property files. In my application.properties
file the correct active profile will be set by the profile of my maven build:
spring.profiles.active=@profileActive@
The maven profiles are dev
, test
and prod
. The maven command looks like that: mvn clean install -Pdev
for example. After the build, my active profile is set to dev
.
Now, I added also some property files to my test/resource
folder to use @TestPropertySource
for my tests. The application.properties
in this folder has the same content as the normal one.
My problem is now, that I the @profileActive@
in application.properties
in my test folder doesnt set the profile of the maven command. So my tests are red because no profile is set and the context could not be loaded.
Is there any way to get the profile set automatically in the application.properties
in test/resource
by using the same maven command?