开发者

spring properties injection doesn't work @Value and <util:properties>

I have a problem injecting properties in a Class with spring.

My applicationContext.xml contains something like this :

开发者_如何学C
<context:annotation-config />
<context:component-scan base-package="life" />
<util:properties id="config" location="classpath:config/files/config.properties"/>

and for example I want to get a boolean in config.properties file :

package life.util;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class LifePath {

    private @Value("#{config.production_mode}")static boolean prodMode;

I have no error but that doesn't work.

If someone have an idea to help me, it will be great.

Johan


It's likely because prodMode is static. I don't think Spring is going to pay any attention to that, it'll only wire up instance fields.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜