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.
精彩评论