我试图让Ehcache 3在不使用Spring引导的情况下使用Spring 4 .
Here is a working example out there which uses Spring Boot,但我正在处理一个没有使用Spring Boot的现有应用程序 .
问题是spring-context-support(添加Spring的缓存注释)要求Ehcache的CacheManager在这个类路径上:net.sf.ehcache.CacheManager
但是,在Ehcache 3中,CacheManager类驻留在另一个类路径上:org.ehcache.CacheManager .
所以,基本上spring-context-support不支持Ehcache 3.你必须直接使用JSR-107注释,而不是Spring提供的注释 .
但显然它适用于Spring Boot . 也许有一种方法可以使它与标准的Spring应用程序一起工作 . 这就是我所希望的 . 我真的想要使用Spring自己的注释而不是JSR-107注释 .
2 回答
实际上,在Spring Caching中没有Ehcache 3的原生支持 .
好消息是,自从Ehcache 3为compliant JCache implementation之后,你就可以实现你想要的Spring缓存 . 一旦您的应用程序上下文中有JCache
CacheManager
,就没有任何东西强迫您使用JCache注释 . 您可以毫无问题地继续使用Spring Caching .你可以找到那个here的演示 .
注意:我正在研究Ehcache
这是ehcache 2到3所有必要更改的简单工作示例:https://imhoratiu.wordpress.com/2017/01/26/spring-4-with-ehcache-3-how-to/
这是新配置的链接:
http://www.ehcache.org/documentation/3.4/xml.html
http://www.ehcache.org/documentation/3.1/107.html#supplement-jsr-107-configurations