【问题标题】:Java maven Junit read systemproperties variable to load property fileJava maven Junit读取systemproperties变量以加载属性文件
【发布时间】:2013-06-10 16:38:29
【问题描述】:

Java Maven Spring Junit 与 web 应用程序

我正在使用以下代码将属性文件加载到弹簧上下文放置器中。

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

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

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

【问题讨论】:

    标签: java spring maven junit maven-3


    【解决方案1】:

    您应该在运行 maven 时使用-D 开关提供RESOURCE_PATH 属性,或者将其放入pom.xml 部分&lt;properties&gt;;像这样:

    <properties>
        <RESOURCE_PATH>put your path here</RESOURCE_PATH>
    </properties>
    

    【讨论】:

    • 我希望它仅适用于测试用例
    猜你喜欢
    • 2018-07-19
    • 1970-01-01
    • 2012-02-19
    • 2012-04-16
    • 2013-01-20
    • 2011-12-15
    • 1970-01-01
    • 2014-04-08
    • 1970-01-01
    相关资源
    最近更新 更多