問題:IllegalArgumentException: error wildcard type pattern not allowed, must use type name****
執行test時,使用@Before("execution(* com.imooc.aop.aspectj.biz.*Biz.*(..))")可以成功測試,配置@Before("pointcut()"),出現IllegalArgumentException: error wildcard type pattern not allowed, must use type name at***錯誤,求解答
代碼如下:
//MoocAspect類 @Component @Aspect public?class?MoocAspect { //?定義兩個切入點 //?匹配方法執行的切入點 @Pointcut("execution(*?com.imooc.aop.aspectj.biz.*Biz.*(..))") public?void?pointcut() { }; //?限定匹配特定類型的連接點 @Pointcut("with(com.imooc.aop.aspectj.biz.*)") public?void?biaPointcut() { }; //?before?advice //?方法一 //?@Before("execution(*?com.imooc.aop.aspectj.biz.*Biz.*(..))") @Before("pointcut()") public?void?before() { System.out.println("Before."); } }
2017-03-11
問題解決了:這里寫錯了??@Pointcut("with(com.imooc.aop.aspectj.biz.*)")?
改成@Pointcut("within(com.imooc.aop.aspectj.biz.*)")
就ok了。
2017-03-11
error wildcard type pattern not allowed, must use type name 這句話的意思是通配符類型不允許,要使用類型的名稱,是什么意思呢?