我正在寻找一种干净的方法来使用从命令行(maven项目)传递的环境值从属性文件加载值 . 然后我计划在Java黄瓜测试中使用加载的值 .
用法:mvn test -Denvironment = staging(然后从staging文件加载值,即application-staging.properties等) .
我知道spring boot提供了配置文件,想知道我是否可以使用通用 spring 框架(注释)来使用干净的方法 .
谢谢@racraman . 我可以使用你在 PropertySource 周围的建议来解决这个问题 . 为了获得不同的环境,我使用了类似的东西:
PropertySource
@PropertySource({"classpath:${env}.properties"}) .
@PropertySource({"classpath:${env}.properties"})
干杯!!!
1 回答
谢谢@racraman . 我可以使用你在
PropertySource
周围的建议来解决这个问题 . 为了获得不同的环境,我使用了类似的东西:@PropertySource({"classpath:${env}.properties"})
.干杯!!!