我正在使用 Maven 配置文件运行 JUnit 测试。
Maven 配置文件看起来是这样的:
<profile>
<id>someProfile</id>
<properties>
...
<some.param>some_value</some.param>
...
</properties>
</profile>
弹簧上下文文件(testContext.xml):
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
...
xmlns:p="http://www.springframework.org/schema/p"
...
xsi:schemaLocation="...">
<bean id="someBean" class="someClass"
scope="singleton"
autowire="byName"
init-method="init"
p:someBeanParam="${some.param}"/>
</beans>
测试课是这样开始的:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/testContext.xml"})
@Configurable
...
运行 maven 后,我看到 testContext.xml 没有改变 - p:someBeanParam仍然有值${some.param}。
你能告诉我这里有什么问题以及如何解决吗?
先感谢您。