日期:2014-05-19 浏览次数:20911 次
<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(); } } }