首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >java.lang.ClassNotFoundException: org.springframework.cache.guava.GuavaCache

java.lang.ClassNotFoundException: org.springframework.cache.guava.GuavaCache
EN

Stack Overflow用户
提问于 2022-02-09 10:44:49
回答 2查看 707关注 0票数 1

背景-

我有一个spring引导应用程序,我将spring-boot-starter-parent版本从1.5.12.RELEASE更新到2.4.0

我的酒里有这种依赖性-

代码语言:javascript
复制
<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>30.1-android</version>
</dependency>

现在当我运行我的应用程序时,我得到了这个错误-

代码语言:javascript
复制
    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cachesEndpoint' defined in class path resource ...

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'guavaCacheManager' defined in class path resource...

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cache.CacheManager]: Factory method 'guavaCacheManager' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/cache/guava/GuavaCache ...

Caused by: java.lang.NoClassDefFoundError: org/springframework/cache/guava/GuavaCache
    at biz.kaar.common.services.cache.TempGuavaCacheConfig.guavaCacheManager(TempGuavaCacheConfig.java:32)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
    ... 43 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.cache.guava.GuavaCache
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
    ... 49 common frames omitted
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-02-18 10:03:02

我通过从我的项目中完全消除番石榴依赖及其引用来解决这个问题。

如果您仍然需要使用缓存,那么尝试使用咖啡因。

票数 1
EN

Stack Overflow用户

发布于 2022-02-17 15:28:05

通过在网络上进行更多的研究,我能够通过向项目添加spring上下文支持来修复在我的项目中发生的相同的异常。我是通过向我的build.gradle添加以下依赖项来做到这一点的

代码语言:javascript
复制
compile("org.springframework:spring-context-support:4.1.7.RELEASE")

spring-context-support是一个库,它包含用于配置缓存的助手方法和类。

下面是我所关注的博客:https://codedevstuff.blogspot.com/2015/07/add-guava-cache-to-spring-boot-to-cache.html

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71048146

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档