多语言展示
当前在线:368今日阅读:84今日分享:32

net.sf.ehcache.CacheException异常解决的方法

下午学习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 does not allow attribute 'maxElementsOnDisk'.最后查出原因并不是因为在ehcache.xml下的默认缓存设置下出现错误的设置。
工具/原料

hibernate缓存机制

方法/步骤
1

出现net.sf.ehcache.CacheException: Error configuring from file:/D:/EclipseWorkspace2/hibernate_06_cache/bin/ehcache.xml错误的原因是ehcache.xml文件配置错误

2

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

3

最方便的建议网上下载一个ehcache.xml原始文件。这样的话需要的时候在设置。原始的defaultCache配置为:   

推荐信息