錯誤如下包結構如下這是我的方法@Before("execution(*com.wisely.highlight_spring4.ch1.aop.DemoMethodService.*(..))") public void before(JoinPoint joinPoint){ MethodSignature signature=(MethodSignature)joinPoint.getSignature(); Method method=signature.getMethod(); System.out.println("方法規則攔截"+method.getName()); }這是運行的錯誤Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.event.internalEventListenerProcessor': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting 'name pattern' at character position 68execution(*com.wisely.highlight_spring4.ch1.aop.DemoMethodService.*(..)) ^ at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:775) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)網上查了各種資料.*(..)就是執行所有方法的意思啊,為什么這里會報錯?
2 回答

阿波羅的戰車
TA貢獻1862條經驗 獲得超6個贊
我猜問題可能是你少了一個空格
@Before("execution(* com.wisely.highlight_spring4.ch1.aop.DemoMethodService.*(..))")
public void before(JoinPoint joinPoint){
MethodSignature signature = (MethodSignature)joinPoint.getSignature();
Method method = signature.getMethod();
System.out.println("方法規則攔截"+method.getName());
}
問題在這* com.wisely

有只小跳蛙
TA貢獻1824條經驗 獲得超8個贊
Caused by: java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting 'name pattern' at character position 68
execution(*com.wisely.highlight_spring4.ch1.aop.DemoMethodService.*(..))
你檢查你的聲明切入點表達式那里有沒有錯,括號的兩個點(..)是沒有錯的
添加回答
舉報
0/150
提交
取消