错误如下包结构如下这是我的方法@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
提交
取消