是否有Spring AOP重新打包的CGLIB版本

Do its have Spring AOP repackaged CGLIB version

我有 spring 个具有会话作用域和 AOP CGLIB 代理的 bean。

    <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>

在 spring-aop-4.2.xsd 中有 <xsd:attribute name="proxy-target-class" type="xsd:boolean" default="true">

Are class-based (CGLIB) proxies to be created? This is the default; in order to switch to standard Java interface-based proxies, turn this flag to "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依赖或者spring-aop v4.2.5已经有重新打包的cglib版本?

Spring 包括一个重新打包的 cglib 版本,并且只使用这个版本。 class 路径上的 cglib 版本无关紧要。只有设置标志很重要。