67,515
社区成员
发帖
与我相关
我的任务
分享
<aop:before method="annotation"
pointcut="execution((@annotation.MyAnnotation *) *(..))"/>
@Override
public MyAnnotation sayHelloAnnotation() {
System.out.println("after annotation");
return null;
}
public void annotation() {
System.out.println("before annotation");
}
public class SpringTest {
private static ClassPathXmlApplicationContext context;
@BeforeClass
public static void setUp() {
try {
context = new ClassPathXmlApplicationContext("bean.xml");
} catch(Exception e) {
e.printStackTrace();
}
}
@Test
public void test() {
try {
HelloApi ha = context.getBean("hello", HelloApi.class);
ha.sayHelloAnnotation();
} catch(Exception e) {
e.printStackTrace();
}
}
}