将dir传递给bean构造函数

时间:2011-08-01 10:54:23

标签: java spring constructor

我有以下bean设置

    <bean id="server-engine"
    class="RuleEngineRESJSE">
    <constructor-arg index="0" value="package.rulesengine.log" />
</bean> 

然而我收到错误:

Constructor threw exception; nested exception is java.lang.IllegalStateException: The value of rulesLogProperty was not found

构造函数只需为rulesLogProperty

获取字符串参数
    public RuleEngineRESJSE(String rulesLogProperty) throws IOException {

    if(rulesLogProperty == null)
        throw new IllegalStateException("The rulesLogProperty value is expected");

    this.log = System.getProperty(rulesLogProperty);

    if(log == null)
        throw new IllegalStateException("The value of rulesLogProperty was not found");

    init();
}

所以我看到异常被抛出。这会让我想到:

this.log = System.getProperty(rulesLogProperty)

是问题,但为什么?

1 个答案:

答案 0 :(得分:0)

一切看起来都适合我。我假设package.rulesengine.log不在正确的位置,虽然这看起来太简单了。