net.sf.ehcache.CacheException异常解决的方法
来源:网络收集 点击: 时间:2024-05-22【导读】:
下午学习hibernate的时候出现如下的异常:%%%% Error Creating SessionFactory %%%%net.sf.ehcache.CacheException: Error configuring from file:/D:/EclipseWorkspace2/hibernate_06_cache/bin/ehcache.xml. Initial cause was Error configuring from input stream. Initial cause was null:42: Element defaultCache does not allow attribute maxElementsOnDisk.最后查出原因并不是因为在ehcache.xml下的默认缓存设置下出现错误的设置。工具/原料morehibernate缓存机制方法/步骤1/4分步阅读
2/4
3/4
4/4
NetBeans
出现net.sf.ehcache.CacheException: Error configuring from file:/D:/EclipseWorkspace2/hibernate_06_cache/bin/ehcache.xml错误的原因是ehcache.xml文件配置错误

由于上边的ehcache.xml文件不是最原始的文件,经过了多次的修改,在本次项目运行一些配置并不需要,所以解决办法是删除异常提示的错误的配置。Element defaultCache does not allow attribute maxElementsOnDisk.意思是defaultCache 下不允许设置maxElementOnDisk属性。删除即可。

最方便的建议网上下载一个ehcache.xml原始文件。这样的话需要的时候在设置。原始的defaultCache配置为:
defaultCache
maxElementsInMemory=10000
eternal=false
timeToIdleSeconds=120
timeToLiveSeconds=120
overflowToDisk=true
/

将ehcache.xml复制到工程的src目录下,运行程序即可解决异常。

版权声明:
1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。
2、本站仅提供信息发布平台,不承担相关法律责任。
3、若侵犯您的版权或隐私,请联系本站管理员删除。
4、文章链接:http://www.1haoku.cn/art_828359.html
上一篇:小度怎么连接手机
下一篇:宝宝辅食西葫芦鲈鱼粥