我是这样为我的应用程序声明Spring属性占位符的:
<context:property-placeholderlocation="classpath:config/base.properties,classpath:config/${target_env}.properties/>
当我将应用程序部署到Tomcat web服务器时,我将目标环境作为参数
-Dtarget_env=dev.
但是当我编写JUnit测试用例时,我如何设置目标环境值?
我得到了答案。我们需要在eclipse中创建环境变量,如下所示:
在eclipse中:Run as -> "Run Configurations" -> Environment -> Create new - (variable =target_env, Value =dev)