当我使用JUnit进行测试时,如何声明Spring属性占位符?

时间:2015-05-22 06:33:12

标签: java spring

这是我为我的应用程序声明Spring属性占位符的方式:

<context:property-placeholderlocation="classpath:config/base.properties,classpath:config/${target_env}.properties/>

当我将我的应用程序部署到Tomcat webserver时,我将目标环境作为参数

 -Dtarget_env=dev.

但是当我编写JUnit测试用例时,如何设置目标环境值?

1 个答案:

答案 0 :(得分:0)

我得到了答案。我们需要在eclipse中创建如下的环境变量:

在eclipse中:运行为 - &gt; &#34;运行配置&#34; - &GT;环境 - &gt;创建新的 - (variable = target_env,Value = dev)