我有一个运行 java8 的 SpringBoot 应用程序。它运行良好,但有时会开始抛出以下错误。java.lang.NoClassDefFoundError: net/sf/ehcache/concurrent/ReadWriteLockSyncat 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)任何帮助,将不胜感激。
2 回答
四季花海
TA贡献1811条经验 获得超5个赞
EhCache 在版本 2 和 3 之间更改了包名称。
net.sf.ehcache 指 EhCache2 中的包(您的应用程序正在尝试查找此版本)
org.ehcache 指的是新的 EhCache3
可能是您有使用 EhCache2 的代码,现在已经失去了依赖性。例如,如果您尝试更新Spring Boot 1.5到Spring Boot 2
要进行进一步测试,请尝试pom.xml使用以下依赖项强制 EhCache2 :
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.10.5</version>
</dependency>
慕容708150
TA贡献1831条经验 获得超4个赞
NoClassDefFoundError
当类在编译时可用并且程序已成功编译和链接但在运行时类丢失时发生。
可能的解决方案:
在这里您正在使用EhCache
,因此您可能对此有一些依赖性。将其EhCache
jar
从存储库复制到您的项目文件夹(可能是lib
您可以添加到的文件夹build path
)。现在您明确给出jar
文件,以便您可以评论相应的依赖项或提供其范围。
现在您可以尝试查看是否再次出现错误。:)
添加回答
举报
0/150
提交
取消