0
votes

I have spring bean with session scope and AOP CGLIB proxy.

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

In spring-aop-4.2.xsd its have <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".

This means that default CGLIB proxy is created. But my maven project don`t have CGLIB dependency I have only spring-context and spring-web and in dependency diagram its have spring-aop but without transitive dependency to cglib. My project compiles and run without to have this dependency:

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

If its need to include cglib dependency or spring-aop v4.2.5 already have repackage cglib version?

1

1 Answers

1
votes

Spring includes a repackaged version of cglib and only uses this version. It does not matter what version of cglib you are having on the class path. Only setting the flag matters.