springboot&maven-使用maven命令更改数据源配置

2j4z5cfb  于 2021-07-23  发布在  Java
关注(0)|答案(1)|浏览(414)

在我的项目(springboot,maven)中,我用 @TestPropertySource({"classpath:flyway.properties", "/queries/test.properties"}) 重写与我的数据源相关的某些属性。我和你一起做测试 mvn clean test 命令。
现在,我想向jenkins管道添加一个新阶段,在两个不同的数据源上执行测试。
当我运行maven命令时,有没有方法覆盖我的文件(test.properties)中的值?或者我可以用两个不同的文件和spring配置文件或者类似的东西: @TestPropertySource({"classpath:flyway.properties", "/queries/test-${env/profile}.properties"}) 如有任何见解,我们将不胜感激。干杯!

h4cxqtbf

h4cxqtbf1#

您可以拥有不同的配置文件,并通过运行以下命令按需激活正确的配置文件: mvn -DargLine="-Dspring.profiles.active=myProfile" clean test

相关问题