java 缓存ech_ehcache获取缓存空指针
報錯日志
Caused by: java.lang.NullPointerException
at com.binfoo.www.module.WeiXinUserModule.(WeiXinUserModule.java:32)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.nutz.lang.born.EmptyArgsConstructorBorning.born(EmptyArgsConstructorBorning.java:16)
... 45 more
shiro.ini配置
cacheManager = org.apache.shiro.cache.ehcache.EhCacheManager
cacheManager.cacheManagerConfigFile = classpath:ehcache.xml
代碼
Cache cache = cacheManager.getCache("bms");
String access_token;
Element ele = cache.get("key");
echcache.xml配置
xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="false"
monitoring="autodetect" dynamicConfig="true" name="bms">
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
/>
maxElementsInMemory="10000"
overflowToDisk="true"
eternal="true"
timeToLiveSeconds="0"
timeToIdleSeconds="0"
diskPersistent="true"
diskExpiryThreadIntervalSeconds="600"/>
ehcache.js配置
var ioc = {
cacheManager : {
type : "net.sf.ehcache.CacheManager",
factory : "net.sf.ehcache.CacheManager#getCacheManager",
args : ["bms"] // 對應shiro.ini中指定的ehcache.xml中定義的name
}
/*
// 如果不需要shiro初始化的Ehcache, 使用下面的方式配置
cacheManager : {
type : "net.sf.ehcache.CacheManager",
factory : "net.sf.ehcache.CacheManager#create"
}
*/
};
總結
以上是生活随笔為你收集整理的java 缓存ech_ehcache获取缓存空指针的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java环境变量path好长_java环
- 下一篇: php下载apk文件源码下载,php实现