为什么 EhCacheProvider 被弃用?
我正在将我的 hibernate 项目配置为使用二级缓存提供程序,以便我可以利用查询缓存。
我添加了对ehcache的依赖:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.2.0</version>
</dependency>
我认为我想要使用的提供程序类是:
net.sf.ehcache.hibernateEhCacheProvider
当我在eclipse中查看引用的库时,我在EhCacheProvider@Deprecated
注释>,以及 SingletonEhCacheProvider
。什么给?我可以使用最新的替代提供商吗?
我正在使用 hibernate 版本 3.4.0.GA,以防万一。
I am configuring my hibernate project to use a 2nd-level cache provider, so that I can take advantage of query caching.
I added a dependency to ehcache:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.2.0</version>
</dependency>
I think that the provider class I want to use is:
net.sf.ehcache.hibernateEhCacheProvider
When I look at the referenced libraries in eclipse, I see the @Deprecated
annotation on EhCacheProvider
, and also on SingletonEhCacheProvider
. What gives? Is there an up-to-date replacement provider that I can use?
I am using hibernate version 3.4.0.GA, in case it matters.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
它们已被弃用,取而代之的是使用其
CacheRegionFactory
实现新 Hibernate 3.3/3.5 SPI 的类。这些实现分别是:net.sf.ehcache.hibernate.EhCacheRegionFactory
net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory
新 SPI 的优点包括:
因此,我们鼓励您使用新的实现。配置是通过以下属性完成的:
它替换了 hibernate.cache.provider_class 属性。
参考资料
They have been deprecated in favor of the classes implementing the new Hibernate 3.3/3.5 SPI with its
CacheRegionFactory
. These implementations are respectively:net.sf.ehcache.hibernate.EhCacheRegionFactory
net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory
Benefits of the new SPI include:
You are thus encouraged to use the new implementations. Configuration is done via the following property:
That replaces the
hibernate.cache.provider_class
property.References
如果您希望使用 Hibernate 4.0.0.Final. 作为 hibernate.cache.region.factory_class 属性的值,请使用:
org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory
和org.hibernate.cache.ehcache.EhCacheRegionFactory
而不是net.sf.ehcache.hibernate.EhCacheRegionFactory
code>否则你最终会遇到一些内部 ClassNotFound 异常
if you wish to use Hibernate 4.0.0.Final. for the value of hibernate.cache.region.factory_class property use:
org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
instead ofnet.sf.ehcache.hibernate.SingletonEhCacheRegionFactory
andorg.hibernate.cache.ehcache.EhCacheRegionFactory
instead ofnet.sf.ehcache.hibernate.EhCacheRegionFactory
Otherwise you will end up with some internal ClassNotFound exceptions
EhCache 2 现已弃用并停止使用。您应该使用 EhCache 3。在 5.3 之后的 Hibernate 版本中,建议使用 JSR-107 (JCache)。为此,需要 2 个依赖项:
第一个依赖项提供与 Hibernate 兼容的 JSR-107 API。第二个是实际的缓存实现 - EhCache 3。
还必须使用新的
RegionFactory
:EhCache 2 is now deprecated and discontinued. You should use EhCache 3 instead. In Hibernate versions after 5.3 it is recommended to use JSR-107 (JCache). In order to do that 2 dependencies are needed:
The first one provides JSR-107 API compliant with Hibernate. The second one is actual cache implementation - EhCache 3.
Also new
RegionFactory
must be used:EhCache 文档说从 Hibernate 3.3 开始你应该使用:(
或
net .sf.ehcache.hibernate.SingletonEhCacheRegionFactory
)The EhCache docs say that from Hibernate 3.3 onward you should use:
(or
net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory
)