gpt4 book ai didi

java - 带有 spring 缓存和 aspectj 的 NoClassDefFoundError

转载 作者:搜寻专家 更新时间:2023-10-31 20:22:34 27 4
gpt4 key购买 nike

我在我的 spring webapp(spring 3.1)中遇到这个错误,我不知道为什么。

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: mypackage/TestCache$AjcClosure1

($AjcClosure1 很奇怪)

如果我在下面的类中注释注释 @Cacheable,错误就消失了。

public class TestCache {

@Cacheable(value ="myCache")
public List<String> getDummyList(){
Logger l = Logger.getLogger(this.getClass());
l.error("calling getDummyList");
ArrayList<String> foo = new ArrayList<String>();
foo.add("foo");
foo.add("bar");
return foo;
}

}

我的 Controller 类(简化):

@Controller
@RequestMapping("/mypage")
public class MyController {


@RequestMapping
public String index(ModelMap model, Locale locale) {
TestCache tc = new TestCache();
...
}
}

Application Context(仅缓存部分):

<cache:annotation-driven mode="aspectj"/>
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cache-manager-ref="ehcache"/>
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:config-location="classpath:ehcache.xml"/>

我尝试了代理和 aspectj 模式(在代理模式下错误较少但缓存什么都不做)

此 Web 应用程序最初是使用 roo 构建的,并使用了 spring mvc 和 webflow。所以 applicationContext.xml 或 webmvc-config.xml 中有很多 xml(我无法理解某些 bean 在做什么)。我在 eclipse 中使用 m2e-wtp 运行 wepapps 并且 pom.xml 使用插件 aspectj-maven-plugin(但不知道它做了什么)

看起来问题与aspectj有关,但我从未使用过aspectJ。如果任何人 spring/java/aspectj guru 可以向我解释是什么导致了这个错误以及我如何使我的缓存工作,那就太棒了! (我只能找到教程,但找不到使用可缓存注释的示例项目)。

最佳答案

问题似乎来自于所有类$AjcClosure[n].class 都没有发布,唯一的方法是删除 web 应用程序,干净启动并重新发布 web 应用程序。

关于java - 带有 spring 缓存和 aspectj 的 NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9727686/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com