0

Java Maven Spring Junit 与 web 应用程序

我正在使用以下代码将属性文件加载到弹簧上下文占位符中。

<context:property-placeholder location="file:${RESOURCE_PATH}/jdbc.properties" />

在 Eclipse Junit 运行时配置中,我定义了“RESOURCE_PATH”,因此当我从 GUI 执行 junit 测试时它运行良好,但当我从 maven 运行时它们失败。

我们可以在运行时定义变量并传入 pom 文件吗?

4

1 回答 1

1

您应该在运行 maven 时RESOURCE_PATH使用switch 提供属性或将其放入 section ;像这样的东西:-Dpom.xml<properties>

<properties>
    <RESOURCE_PATH>put your path here</RESOURCE_PATH>
</properties>
于 2013-06-10T16:54:43.063 回答