Spring AOP uses either JDK dynamic proxies or CGLIB to create the proxy for a given target object. If the target object to be proxied, does not implement any interfaces then a CGLIB proxy will be created. In this situation if CGLIB is not present in the classpath following exception will be thrown
org.springframework.aop.framework.AopConfigException: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
Solution
Add CGLIB 2 binaries on your application's classpath
1. Download CGLIB2 jars
Download CGLIB2 jars and put it in application classpath.
2. Add Maven Dependency
If you are using Maven as build tool then add the following dependency to the POM file.
File: pom.xml
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
</dependency>
Comments