Getting an EhCache instance with Spring... intelligently

Viewed 44275

I need to get a specific EhCache instance by name and I'd prefer to autowire if possible. Given the following automatically configured controller, how can I autowire in the cache instance I'm looking for?

@Controller 
public class MyUniqueService {
    ...
}

<beans ...>
    <ctx:component-scan base-package="my.controllers"/>
    <mvc:annotation-driven />
</beans>

How do I configure EhCache in my application context? I don't see any log messages from EhCache about it loading the ehcache.xml file in my /WEB-INF/ directory. How do I make it load it?

How can I integrate EhCache with my Spring application to have it load the ehcache.xml file from my /WEB-INF/ directory and autowire a cache by a given name into my MyUniqueService controller?

4 Answers
Related