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 assembly:
spring.profiles.active=@profileActive @
Maven profiles: dev
, test
and prod
. The maven command looks like this: mvn clean install -Pdev
for example. After the build, my active profile is set to dev
.
Now I have added some property files to my test/resource
folder to use @TestPropertySource
for my tests. application.properties
in this folder has the same content as regular.
My problem is that I @ profileActive@
in application.properties
in my test folder does not specify the maven command profile. Therefore, my tests are red because the profile is not defined and the context cannot be loaded.
Is there a way to automatically set the profile in application.properties
in test/resource
using the same maven command?
source share