I'm currently using Spring 4.3.4 to execute a "Simple Aspect Example program". I tried using both XML and Annotation but it gives me BeanCreationException error.
Error creating bean with name 'org.springframework.aop.config.internalAutoProxyCreator'
I've added below mentioned dependencies:
- spring-core 4.3.4
- spring-beans 4.3.4
- spring-context 4.3.4
- spring-aspects 4.3.4
Main:
public class Main {
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("com/sonyx64/spring/aop/config/Beans.xml");
Camera camera = (Camera) context.getBean("camera");
camera.snap();
context.close();
}}
Camera Class:
public class Camera {
public void snap() {
System.out.println("SNAP!");
}
}
Logger Class:
public class Logger {
public void aboutToTakePhoto() {
System.out.println("About To Take Photo");
}
}
Beans.xml
<bean id="camera" class="com.sonyx64.spring.aop.Camera"></bean>
<bean id="logger" class="com.sonyx64.spring.aop.Logger"></bean>
<aop:config>
<aop:pointcut expression="execution(void com.sonyx64.spring.aop.Camera.snap())"
id="camerasnap" />
<aop:aspect id="loggeraspect" ref="logger">
<aop:before method="aboutToTakePhoto" pointcut-ref="camerasnap" />
</aop:aspect>
</aop:config>
Please suggest me an appropriate solution to deal with this exception.

The issue is with the particular version of maven repository jar "aspectjweaver-1.8.9.jar". Running with the previous version 1.8.8 solved the issue.
POM.xml: