Spring.xml配置文件
<bean id="helloWorldService" class="cn.javass.spring.chapter6.service.impl.HelloWorldService"/>
<bean id="aspect" class="cn.javass.spring.chapter6.aop.HelloWorldAspect"/>
<aop:config>
<aop:pointcut id="pointcut" expression="execution(* cn.javass..*.*(..))"/>
<aop:aspect ref="aspect">
<aop:before pointcut-ref="pointcut" method="beforeAdvice"/>
<aop:after pointcut="execution(* cn.javass..*.*(..))" method="afterFinallyAdvice"/>
</aop:aspect>
</aop:config>
test测试类
@Test
public void testHelloworld() {
ApplicationContext ctx = new ClassPathXmlApplicationContext("chapter6/helloworld.xml");
IHelloWorldService helloworldService =
ctx.getBean("helloWorldService", IHelloWorldService.class);
helloworldService.sayHello();
}