2016-04-22 54 views
0

我有Spring bean的会话范围和AOP CGLIB代理。是否有Spring AOP重新包装的CGLIB版本

<beans xmlns="http://www.springframework.org/schema/beans" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:context="http://www.springframework.org/schema/context" 
      xmlns:aop="http://www.springframework.org/schema/aop" 
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> 

    <bean id="restClient" class="com.test.services.RestClient" scope="session"> 
       <constructor-arg ref="dataSource"/> 
       <aop:scoped-proxy /> <!--proxy-target-class="true" default is true to use cglib--> 
    </bean> 
    </beans> 

在春天的AOP-4.2.xsd其具有<xsd:attribute name="proxy-target-class" type="xsd:boolean" default="true">

是否基于类的(CGLIB)代理产生的呢?这是默认设置;在 为了切换到标准的基于Java接口的代理服务器,将这个 标志设置为“false”。

这意味着将创建默认的CGLIB代理。但我的Maven项目没有CGLIB依赖性我只有spring-context和spring-web,并且在依赖关系图中,它具有spring-aop但没有传递依赖关系到cglib。我的项目编译和运行没有有这种依赖性:

 <dependency> 
      <groupId>cglib</groupId> 
      <artifactId>cglib</artifactId> 
      <version>3.2.1</version> 
     </dependency> 

如果它需要包括CGLIB的依赖或弹簧AOP V4.2.5已经改头换面CGLIB的版本?

回答

1

Spring包含一个重新打包的cglib版本,只使用这个版本。不管你在类路径中使用什么版本的cglib。只有设置标志很重要。

相关问题