Johan
Johan

Reputation: 33

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 :

<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

Upvotes: 3

Views: 4274

Answers (1)

skaffman
skaffman

Reputation: 403581

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.

Upvotes: 3

Related Questions