In my Spring Application, I have a bean defined in my xml as such:
<beans:bean id="tokenStore" class="com.myproject.core.security.RemoteTokenStore" />
I also have this class I created, and annotated with @Service:
com.myproject.core.service.CacheService
In my RemoteTokenStore.java file, if I try to Autowire CacheService like so:
@Autowired
private CacheService cacheService;
It is always null. How to I fix this?
Add this to your context xml file:
Once this has been specified your annotations will be processed and your components will be identified by Spring.
If you haven’t already you will also need to include the
spring-contextdependency on your classpath and the context namespace in your application XML.Reading this: http://www.mkyong.com/spring/spring-auto-scanning-components/ might help