Error tip : 1:java.lang.illegalstateexception:failed to load ApplicationContext
2:error creating Bean with Name ' UserService ' defined in class path resource [Userservice.xml]: initialization of Bean FAI Led Nested exception is Org.springframework.aop.framework.AopConfigException:Cannot proxy target class because CGLIB2 are not Available. Add CGLIB to the class path or specify proxy interfaces.
3:cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
root cause : The root cause is a missing cglib package because the Web has an error while loading the spring configuration file (Applicationcontext.xml), and the error is 3 (cglib2 unavailable).
the proxy configuration in Applicationcontext.xml is as follows :
<!--specify to use Cglib--
<aop:aspectj-autoproxy proxy-target-class= "true"/>
<tx:advice id= "Txadvice" transaction-manager= "TransactionManager" >
<tx:attributes>
<tx:method name= "*"/>
</tx:attributes>
</tx:advice>
<!--provides transactional enhancements through AOP configuration, allowing all methods of all beans under the service package to have transactions--
<aop:config proxy-target-class= "true" >
<aop:pointcut id= "Servicemethod" expression= "Execution (* com.luxl.service). *(..))" />
<aop:advisor pointcut-ref= "Servicemethod" advice-ref= "Txadvice"/>
</aop:config>
Workaround: Add the Cglib package to maven as follows:
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
</dependency>