首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

spring中用注解方式实现AOP,该如何解决

2012-03-09 
spring中用注解方式实现AOP我在 xml中配置是可以的然后我在源文件里配置片段如下[codeJava][/code]@Point

spring中用注解方式实现AOP
我在 xml中配置是可以的
然后我在源文件里配置片段如下
[code=Java][/code]@Pointcut("execution(* com.gameart.logic.Logic.*(..)) and args(params)")
public void logic(){}

@Before("logic()")
public void beforeLogic(Object... params){
debug.debug("before logic..."+params[0]);
}
@AfterReturning("logic()")
public void afterLogic(Object... params){
debug.debug("after logic..."+params[0]);
}
出现错误是Caused by: java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut 
如果我把@poingcut及logic这个方法去掉,然后再@before和@after方法里都写上execution(。。。)是可以执行的,就是想用pointcut就出错了,这是为啥呢
以下是正确的,就是不能用pointcut
[code=Java][/code]@Before("execution(* com.gameart.logic.Logic.*(..)) and args(params)")
public void beforeLogic(Object... params){
debug.debug("before logic..."+params[0]);
}
@AfterReturning("execution(* com.gameart.logic.Logic.*(..)) and args(params)")
public void afterLogic(Object... params){
debug.debug("after logic..."+params[0]);
}



[解决办法]
学习了!!!

热点排行