Pointcut is not well-formed: expecting 'name pattern' at character position 58的問題
阿新 • • 發佈:2019-02-14
今天剛學spring的aop的時候,用到了切點方面的知識。在測試的時候丟擲了Pointcut is not well-formed: expecting 'name pattern' at character position 58的異常。錯誤指定在使用註解@Pointcut那裡。
package com.aop.aspect; import org.aspectj.lang.annotation.After; import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.AfterThrowing; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; @Aspect public class RoleAspect { @Pointcut("execution(*com.aop.service.impl.RoleServiceImpl.printRole(..))") public void print(){ } @Before("print()") public void before(){ System.out.println("before..."); } @After("print()") public void after(){ System.out.println("after..."); } @AfterReturning("print()") public void afterReturning(){ System.out.println("afterReturning..."); } @AfterThrowing("print()") public void afterThrowing(){ System.out.println("afterThrowing..."); } }
我檢查了很多遍和書上的程式碼是一樣的。然後不斷執行也是不斷丟擲異常。
最後仔細看書是那個Pointcut("execution(* com 這裡的問題。
*後面要加個空格
最後就可以跑起來了。
要注意小細節。