Pointcut is not well-formed: expecting 'identifier' at character position 0

异常信息如下:

 

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'collectionBeanId' defined in class path resource [applicationContext.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJPointcutAdvisor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting 'identifier' at character position 0
* com.java.spring..*.*(..)
^

 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:405)
 at java.security.AccessController.doPrivileged(Native Method)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
 at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
 at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
 at com.java.spring.demo.SpringDemo6.main(SpringDemo6.java:9)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJPointcutAdvisor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting 'identifier' at character position 0
* com.java.spring..*.*(..)

 

解决方案:

原因是因为配置<aop:pointcut  id="mycut" expression="* com.java.spring..*.*(..)" />
expression时,没有指定"execution"造成的错误。

正确的配置如下:
    <!-- 配置AOP面向切面-->
    <aop:config>
           <!-- 配置需要面向切面的类 -->
         <aop:aspect id="asp" ref="personInterceptor">
             <!-- 配置切入点,指从什么包下面搜索需要配置面向切面的类. -->
             <aop:pointcut  id="mycut" expression="execution(* com.java.spring..*.*(..))" />
             <!-- 前置方法 -->
             <aop:before pointcut-ref="mycut" method="doAccessCheck"/>
             <!--  后置方法-->
             <aop:after-returning pointcut-ref="mycut" method="doAfterRetruing"/>
             <!-- 例外方法 -->
             <aop:after-throwing pointcut-ref="mycut" method="doAfterThrowing"/>
             <!-- 最终方法 -->
             <aop:after pointcut-ref="mycut" method="doAfter"/>
         </aop:aspect>
    </aop:config>

 

你可能感兴趣的:(character)