Reputation: 696
I'm using Spring 4.1.4 and Ehcache 2.9 and caching using the @Cacheable
annotation.
I've noticed that every public class that has a method with this annotation must be referenced in
applicationContext.xml
as follows
<bean class="com.example.web.Test"/>
this forces me to add every public class that i want to cache into the applicationContext.
Is there a way to overcome this?
Thanks
Upvotes: 0
Views: 413
Reputation: 120761
Of course @Cacheable
works only for spring beans.
There are many ways to instantiate a spring bean, explicite xml configuration <bean class="..."/>
is only one. An other way is to enable the component scan and annotate the class with @Component
or @Service
(or some other) annotations.
Upvotes: 1