java – 无法使用ehcache配置JPA

前端之家收集整理的这篇文章主要介绍了java – 无法使用ehcache配置JPA前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我一直在尝试使用ehcache配置JPA但直到现在都没有成功.我正在做的配置是:

> persistence.xml

sql=TRACE"/>
           

> ehcache.xml

> Product.java

@Entity
@Table(name="PRODUCT")
@NamedQueries({@NamedQuery(name="getAllProducts",query = "select products from Product products")})
public class Product implements Serializable {}

我没有得到任何例外,但我看不到ehcache在日志中打印的ehcache没有特定的功能.
如果有人可以提供帮助,我将非常感激.

最佳答案
在persistence.xml中添加以下属性

在类路径中添加以下jar:ehcache-core-2.4.4.jar,ehcache-openjpa-0.2.0.jar和slf4j-api-1.6.1.jar.

就这样.

Jar下载:

>链接http://ehcache.org/downloads/catalog?activated=true
> ehcache-core-2.4.4.jar和slf4j-api-1.6.1.jar – ehcache-core-2.4.4-distribution.tar.gz module
> ehcache-openjpa-0.2.0.jar – ehcache-openjpa-0.2.0-distribution.tar.gz

参考

> L2缓存解释 – http://blogs.oracle.com/carolmcdonald/entry/jpa_caching
> OpenJPA L2缓存实施 – http://openjpa.apache.org/builds/1.0.2/apache-openjpa-1.0.2/docs/manual/ref_guide_caching.html
> Ehcache OpenJPA实施 – http://www.ehcache.org/documentation/user-guide/openjpa-provider

原文链接:https://www.f2er.com/java/437782.html

猜你在找的Java相关文章