即使类实现接口时也使用CGLIB代理的Spring [英] spring using CGLIB proxy even when class implements interface

查看:0
本文介绍了即使类实现接口时也使用CGLIB代理的Spring的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Spring AOP来拦截我的GWT-RPC应用程序的方法(使用GWT-Server库,这样RPC服务就不会扩展RemoteServiceServlet)。当我将WAR部署到Tomcat并启动应用程序时,CGLIB由于某种原因而失败。但我不明白为什么CGLIB一开始就被用来代理。既然我的RPC类实现了接口,它不应该使用JDK动态代理吗?

我需要执行什么操作才能调试此问题?敬请指教。

注意:仅供参考,Spring遇到此异常,但我认为这是另一个问题,我无法理解为什么CGLIB代理会出现在图片中。

Caused by: net.sf.cglib.core.CodeGenerationException: net.sf.ehcache.CacheException-->Another unnamed CacheManager already exists 
in the same VM. Please provide unique names for each CacheManager in the config 
or do one of following:
1. Use one of the CacheManager.create() static factory methods to reuse same    CacheManager with same name or create one if necessary
2. Shutdown the earlier cacheManager before creating new one with same name.

推荐答案

为其他(极少数)可能会犯同样错误的人回答。

Spring AOP的方面设置不正确,实际上试图以上下文中的几乎所有类为目标,这就是EhCache开始导致问题的原因,因为有多个CacheManager实例(由于CGLIB代理,因为CacheManager不实现接口)

这篇关于即使类实现接口时也使用CGLIB代理的Spring的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆