This question already has an answer here:
- Why is my Spring @Autowired field null? 7 answers
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