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



在我的项目(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"})

任何见解将不胜感激。干杯!

您可以有不同的配置文件,并根据需要激活正确的配置文件:

mvn -DargLine="-Dspring.profiles.active=myProfile" clean test

最新更新