Use spring.profiles.active=@profileActive@ in property file of test/resource folder

有些话、适合烂在心里 提交于 2020-01-06 05:30:20

问题


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?

来源:https://stackoverflow.com/questions/47833555/use-spring-profiles-active-profileactive-in-property-file-of-test-resource-fol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!