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

2025-10-28 14:21:18

1、Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException

at java.lang.Class.getDeclaredConstructors0(Native Method)

at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)

at java.lang.Class.getConstructor0(Class.java:2699)

at java.lang.Class.newInstance0(Class.java:326)

at java.lang.Class.newInstance(Class.java:308)

at org.hibernate.cfg.SettingsFactory.createCacheProvider(SettingsFactory.java:327)

at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:219)

at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)

at com.softeem.test.Demo.main(Demo.java:22)

Caused by: java.lang.ClassNotFoundException: net.sf.ehcache.CacheException

at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

at java.lang.ClassLoader.loadClass(ClassLoader.java:252)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

... 10 more

异常错误截图

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

2、出现此情况只需要添加一个jar包即可解决,百度搜索“ehcache.jar”下载

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

3、下载后倒入工程,这里小编倒入的是user Library里边

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

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

4、倒入后重新运行,成功解决Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException

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

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

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢