aspectj - Aspect not working witha spring bean -
i trying create simple aspect . here simple spring bean
public class simpleservice { public void sayhello(){ system.out.println("hi"); } }
here aspect class
@aspect public class simpleaspect { @before("execution(void sayhello())") public void entering(){ system.out.println("entering.."); } }
here configuration file
<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemalocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <aop:aspectj-autoproxy/> <bean id="service" class="com.schatt.service.simpleservice"></bean>
my understanding when try invoke simpleservice.sayhello() , before aspect called , after sayhello() called.but aspect not getting triggered.can not understand missing here.
the aspect needs created spring (in oder apply proxying).
<bean id="simpleaspect" class="package-name.simpleaspect"></bean>
Comments
Post a Comment