java.lang.NoClassDefFoundError: net/sf/ehcache/

我有一个运行 java8 的 SpringBoot 应用程序。它运行良好,但有时会开始抛出以下错误。


java.lang.NoClassDefFoundError: net/sf/ehcache/concurrent/ReadWriteLockSync

at net.sf.ehcache.store.MemoryStore$LockProvider.getSyncForKey(MemoryStore.java:1038)

at net.sf.ehcache.Cache.tryRemoveImmediately(Cache.java:2170)

at net.sf.ehcache.Cache.get(Cache.java:1756)

at org.springframework.cache.ehcache.EhCacheCache.lookup(EhCacheCache.java:142)

at org.springframework.cache.ehcache.EhCacheCache.get(EhCacheCache.java:67)

at org.springframework.cache.interceptor.AbstractCacheInvoker.doGet(AbstractCacheInvoker.java:73)

at org.springframework.cache.interceptor.CacheAspectSupport.findInCaches(CacheAspectSupport.java:527)

at org.springframework.cache.interceptor.CacheAspectSupport.findCachedItem(CacheAspectSupport.java:492)

at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:374)

at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:316)

at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)

at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)

任何帮助,将不胜感激。


月关宝盒
浏览 449回答 2
2回答

四季花海

EhCache 在版本 2 和 3 之间更改了包名称。net.sf.ehcache 指 EhCache2 中的包(您的应用程序正在尝试查找此版本)org.ehcache 指的是新的 EhCache3可能是您有使用 EhCache2 的代码,现在已经失去了依赖性。例如,如果您尝试更新Spring Boot 1.5到Spring Boot 2要进行进一步测试,请尝试pom.xml使用以下依赖项强制 EhCache2 :&nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>net.sf.ehcache</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>ehcache</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <version>2.10.5</version>&nbsp; &nbsp; </dependency>

慕容708150

NoClassDefFoundError&nbsp;当类在编译时可用并且程序已成功编译和链接但在运行时类丢失时发生。可能的解决方案:在这里您正在使用EhCache,因此您可能对此有一些依赖性。将其EhCache&nbsp;jar从存储库复制到您的项目文件夹(可能是lib您可以添加到的文件夹build path)。现在您明确给出jar文件,以便您可以评论相应的依赖项或提供其范围。现在您可以尝试查看是否再次出现错误。:)
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java