vendredi 27 mai 2016

spring @value returns null [duplicate]

This question already has an answer here:

I'm using spring 3.2.2 and what to inject some string in my .properties file into a class. But always get null.

In my applicationContext.xml:

....
<context:component-scan base-package="com.mypackage">
     <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/
</context:component-scan>
<context:property-placeholder location="classpath:/config/core/abc.properties"/>
....

in abc.properties:

path=testpath

in java code:

package com.mypackage
@Component
public class myclass implements Imyclass {
@Value("${path}")
private String path; //this always is null
...
}

what I'm missing here?




Aucun commentaire:

Enregistrer un commentaire