java - 使用 EhCache 配置 OpenJPA 1.3.1 : plugin/alias not found

标签 java ehcache openjpa

我正在尝试使用 openjpa 配置 ehcache。我收到以下错误:

org.apache.openjpa.lib.util.ParseException: 
Instantiation of plugin "DataCacheManager" with value "ehcache" caused an error 
"java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: ehcache". 
The alias or class name may have been misspelled, or the class may not have be available in the class path. 
Valid aliases for this plugin are: [default]

这是我从 persistence.xml 中摘录的内容:

        <property name="openjpa.QueryCache" value="ehcache"  />
        <property name="openjpa.DataCacheManager" value="ehcache" />

这是我的 ehcache.xml:

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true" monitoring="autodetect" dynamicConfig="true">

  <!--  -->
  <cache name="openjpa" maxElementsInMemory="10000"
    maxElementsOnDisk="1000" eternal="false" overflowToDisk="true"
    diskSpoolBufferSizeMB="20" timeToIdleSeconds="300"
    timeToLiveSeconds="600" memoryStoreEvictionPolicy="LFU"
    transactionalMode="on" />
</ehcache>

这是我的 pom.xml 插件依赖项: 网络SF缓存 ehcache-openjpa 0.2.0

还有其他方式配置openjpa+ehcache吗?

最佳答案

是的,它应该可以工作。确保 ehcache-openjpa jar 位于您的类路径中。我知道如果您在容器环境(即 WAS)中运行,这会稍微复杂一些。

[更新]

我知道我曾经有过这个工作,我必须对 WAS 共享库做一些有趣的事情才能让它工作,但我找不到任何笔记。我模糊地记得问题与 OpenJPA 在启动时未检测到 Ehcache 有关,因此我们没有注册“ehcache”别名。

尝试使用以下属性配置 OpenJPA:

<property name="openjpa.QueryCache" value="net.sf.ehcache.openjpa.datacache.EhCacheQueryCache"/> <property name="openjpa.DataCacheManager" value="net.sf.ehcache.openjpa.datacache.EhCacheDataCacheManager"/> <property name="openjpa.DataCache" value="net.sf.ehcache.openjpa.datacache.EhCacheDataCache"/> <property name="openjpa.RemoteCommitProvider" value="net.sf.ehcache.openjpa.datacache.NoOpRemoteCommitProvider"/>

[/更新]

关于java - 使用 EhCache 配置 OpenJPA 1.3.1 : plugin/alias not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3521271/

相关文章:

JavaFX 自定义 ScrollBar 在滚动时将事件传递给 TableView

java - 有没有办法使基于 Ehcache 文件的配置覆盖编程配置?

grails - Grails EH缓存对象作为参数问题

java - OpenJPA 将 1 <> 1 添加到 WHERE 子句

sql-server-2008 - intellij 想法,生成具有关系的持久性映射

java - 如何在Android上缓存数据?

java - 通过android studio将嵌入式条形码扫描仪添加到 fragment 到我的应用程序中

hibernate - Hibernate 的二级缓存是否/可以用于 COUNT() 操作?

java - 为 Hibernate @ColumnTransformer 打开 JPA 等价物

java - 使用 foreach 打印多维数组