【问题标题】:Configuring proxing beans in Spring aop + cglib在 Spring aop + cglib 中配置代理 bean
【发布时间】:2012-12-20 11:22:37
【问题描述】:

我们有一个 Spring 3.1 Web 应用程序,它使用带有 cglib 库的 spring-aop。 spring.xml:

<context:annotation-config/>
<aop:aspectj-autoproxy proxy-target-class="true"/>

这意味着将使用 cglib 为每个 bean 创建一个代理。

现在我们需要使用带有 com.mchange.v2.c3p0.ComboPooledDataSource 的数据库连接池 bean:

<bean id="connectionPool" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<!-- here are some properties -->
</bean>

问题是 ComboPooledDataSource 类被标记为 final。而且 cglib 不能代理 final 类。

如何标记“connectionPool” bean 不被代理?

【问题讨论】:

  • 你的切入点定义是什么?为什么Spring认为数据源需要代理?

标签: spring aop spring-aop cglib


【解决方案1】:

基本上你应该使用不需要代理的排除模式。

Please refer the link for more details:-

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-06
    • 1970-01-01
    • 2015-01-19
    • 1970-01-01
    • 1970-01-01
    • 2013-10-13
    • 2010-10-29
    相关资源
    最近更新 更多