解决Pointcut is not well-formed

来源:互联网 发布:数据库建表 编辑:程序博客网 时间:2024/05/21 11:11

新手刚学习Spring,使用注解时

@Before("execution(*com.zhazhapan.spring.springtest.chapter.one.aop.DemoMethodService.*(..))")

总是报错

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aopConfig': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting 'name pattern' at character position 79execution(*com.zhazhapan.spring.springtest.chapter.one.aop.DemoMethodService.*(..))                                                                               ^    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)    at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:84)    at com.zhazhapan.spring.springtest.chapter.one.aop.Main.main(Main.java:14)Caused by: java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting 'name pattern' at character position 79

终于在stackoverflow上面找到了解决方案,原来是*之间需要空格,修改注解如下即可

@Before("execution(* com.zhazhapan.spring.springtest.chapter.one.aop.DemoMethodService.* (..))")//注意多了空格哦
阅读全文
0 0
原创粉丝点击