2016-04-22 33 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。只有設置標誌很重要。

相關問題