如何在资源类中自动连接属性值

时间:2015-09-16 06:55:08

标签: spring properties dependency-injection

我正在尝试自动将属性值连接到Resource类,当我启动服务器时,值为属性设置,当我运行我的应用程序时,值变为零。

我的资源类:

private int maxAge;

    @Value("${max_age}")
    public void setMaxAge(int maxAge) {
        this.maxAge = maxAge;
    }

context.xml中:

<context:property-placeholder location="classpath:myWebApplication/test.properties" />
<bean id="resource" class="RestResource">
    <property name="maxAge" value="${max_age}"></property>
  </bean>

我正在使用jersey-spring3 jar

有人可以让我知道我在做什么。

1 个答案:

答案 0 :(得分:0)

删除@Value("${max_age}"),你会没事的!