0
我们有一个经典的Maven,Spring(3.1.1)应用程序,我们在其中创建了一个applicationContext.xml。如何累积财产占位符?
在这个文件中,我们已经在classpath中声明了一个具有外部文件和文件的属性占位符。 在这里,在这里另外一个问题找到了一个例子:
<context:property-placeholder location="file:${ADMIN_HOME}/db.properties,classpath:configuration.properties"
ignore-unresolvable="false" ignore-resource-not-found="false" />
这是工作。
但是现在,我们有一个特定的JUnit测试配置文件。 在这个配置文件中,我们导入了第一个配置文件,并为经典声明的测试添加了一个属性占位符。
<import resource="applicationContext.xml" />
<context:property-placeholder location="classpath:configuration-test.properties"
ignore-unresolvable="false" ignore-resource-not-found="false" />
我们在JUnit测试中从configuration-test.properties注入了一个值。
@Value("${junit.user.login}")
private String login;
但是,当我们启动JUnit时,会引发错误。 关键“junit.user.login”未解析。
我们不知道为什么。 有什么想法?
谢谢。
是的。 @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(“/ applicationContext-test.xml”) public class DocumentServiceTest {} – MychaL 2014-09-10 08:36:24
我们之前没有问题在主配置文件中添加外部文件。所有测试都在进行,直到我们有了这个新功能。这是添加“file:$ {ADMIN_HOME} /db.properties”创建回归的事实。 – MychaL 2014-09-10 08:38:42
在这种情况下,我认为问题出在运行测试时未知的$ {ADMIN_HOME}。也许尝试使用额外的-DADMIN_HOME = –
Nadir
2014-09-10 10:30:46