我正在尝试使用 Infinispan 作为 Openshift 上 JBoss AS 7 托管的 Java 应用程序的缓存。
我在 standalone.xml
中有以下集群配置。
<cache-container name="cluster" aliases="ha-partition" default-cache="default">
<transport lock-timeout="60000"/>
<replicated-cache name="default" mode="SYNC" batching="true" start="EAGER">
<locking isolation="REPEATABLE_READ"/>
</replicated-cache>
</cache-container>
我尝试使用以下代码片段访问缓存。
@Resource(lookup = "java:jboss/infinispan/container/cluster")
EmbeddedCacheManager container;
private Cache<String, Integer> foo = container.getCache("foo", true);
但是,container.getCache
所在行会引发 NullPointerException
。这可能是因为查找
未能找到容器
的值。
我做错了什么?
最佳答案
您只能在 @postconstuct
方法中使用 getCache
调用
关于java - 将 Infinispan 的 EmbeddedCacheManager 与 Openshift 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19220652/