异常如下:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in file [D:\Develop\Spring_1600_AOP_xml\bin\com\bjsxt\impl\UserDAOImpl.class]: 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 'illegal identifier start (。)' at character position 45
execution(public * com.bjsxt.service..*.add(。。))
                                             ^

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:471)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:700)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at com.bjsxt.service.UserServiceTest.testAdd(UserServiceTest.java:21)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
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 'illegal identifier start (。)' at character position 45
execution(public * com.bjsxt.service..*.add(。。))
                                             ^

at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:289)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1114)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1017)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
    at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:92)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:101)
    at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:103)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:285)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:958)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:930)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:465)
    ... 33 more
Caused by: 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 'illegal identifier start (。)' at character position 45
execution(public * com.bjsxt.service..*.add(。。))
                                             ^

at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:164)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:125)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:281)
    ... 48 more
Caused by: java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting 'illegal identifier start (。)' at character position 45
execution(public * com.bjsxt.service..*.add(。。))
                                             ^

at org.aspectj.weaver.tools.PointcutParser.resolvePointcutExpression(PointcutParser.java:335)
    at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:310)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:211)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:197)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:186)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.getMethodMatcher(AspectJExpressionPointcut.java:172)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.buildSafePointcut(AbstractAspectJAdvice.java:187)
    at org.springframework.aop.aspectj.AspectJPointcutAdvisor.<init>(AspectJPointcutAdvisor.java:51)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
    ... 50 more

解决方案如下

解决方案:

原因是因为配置<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>

例如:

<bean id = "logInterceptor" class="com.bjsxt.aop.LogInterceptor"></bean>
    <aop:config>
        <aop:pointcut expression="execution(public * com.bjsxt.service..*.add(..))"        
         id="servicePointcut"/>
         <aop:aspect id="logAspect" ref="logInterceptor">
         <aop:before method="before" pointcut-ref="servicePointcut"/>
         </aop:aspect>        
    </aop:config>

Pointcut is not well-formed: expecting 'identifier' at character position 0的更多相关文章

  1. Pointcut is malformed: Pointcut is not well-formed: expecting 'identifier' at character position 0 ^

    错误提示: 解决方法:指定execution 在执行目标方法之前指定execution 例如: import org.aspectj.lang.annotation.Aspect; import or ...

  2. Pointcut is not well-formed: expecting 'identifier' at character position 0 ^ || Pointcut is not well-formed: expecting ')' at character position 11 ^

    错误提示: 解决方法1:指定execution 在执行目标方法之前指定execution 解决方法2:可能是execution写错了.请仔细检查. 其他——execution参数设置(带问好的可以不配 ...

  3. thinkphp3错误:syntax error, unexpected 'list' (T_LIST), expecting identifier (T_STRING)

    syntax error, unexpected 'list' (T_LIST), expecting identifier (T_STRING) 出现这个错误的原因是,list是php的一个函数,系 ...

  4. Spring AOP表达式报错:Pointcut is not well-formed: expecting 'name pattern' at character position

    问题现象: java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test ...

  5. Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting 'name pattern' at character position 36

    例: <aop:config> <aop:pointcut expression="execution(* com.zsn.Service.Impl.*.*(..))&qu ...

  6. Pointcut is not well-formed: expecting 'name pattern' at character position 53

    报错内容: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataso ...

  7. Pointcut is not well-formed: expecting 'name pattern' at character position 36

    Pointcut is not well-formed: expecting 'name pattern' at character position 36 学习了:http://blog.csdn. ...

  8. Pointcut is not well-formed: expecting 'name pattern' at character position

    配置aop报错:原因是配置切点表达式的时候报错了, 星号后面没有加空格: <aop:config> <aop:pointcut id="transactionPointcu ...

  9. ( ! ) Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in D:\demo\code\yolo\index\index.php on li

    sql语句为:$sql="select count(*) from com where a_id=$v['id']"; 出现以下错误: 原因: 变量没有用花括号引起来 改为:  $ ...

随机推荐

  1. iOS 中constraint 不等于约束和低优先级约束使用的简单体会

    看了些文章发现,在使用constraint时,不等于约束往往是和低优先级约束成对使用的,这样才能实现他们的效果. 看看例子 下面是在3.5存屏幕下的效果 图1,竖屏,在满足>=50的前提下,可以 ...

  2. Java for LeetCode 166 Fraction to Recurring Decimal

    Given two integers representing the numerator and denominator of a fraction, return the fraction in ...

  3. Codeforces 390A( 模拟题)

    Inna and Alarm Clock Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64 ...

  4. [Android UI] shape和selector的结合使用

    shape和selector是Android UI设计中经常用到的,比如我们要自定义一个圆角Button,点击Button有些效果的变化,就要用到shape和selector.可以这样说,shape和 ...

  5. Linux使用tcpdump命令抓包保存pcap文件wireshark分析

    [root@ok Desktop]# yum search tcpdump Loaded plugins: fastestmirror, refresh-packagekit, security Lo ...

  6. .NET 下各种Resource的读取方式

    1) Embedded Resource (Build Action 设置为 Embedded Resource) 在运行时使用GetManifestResourceStream读取 Image.Fr ...

  7. 拼接JSONStringer出现的不正确的情况。

    错误现象: 错误分析及其解答: JSONStringer可以直接嵌套JSONArray,JSONArray可以作为JSONStringer的值.我错误的原因是本质是:JSONArray存放的是JSON ...

  8. uva 11380(最大流+拆点)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=36707 思路:根据题意拆点建图即可. #include<io ...

  9. 驱动模式使用__try __excpet

    内核模式下判断内存可读可写(下面两个函数是判断ring3的内存.我也搞不懂有啥用) VOID ProbeForRead( IN CONST VOID *Address, IN SIZE_T Lengt ...

  10. img 默认是行内元素,它旁边的空格是会保留的

    img 默认是行内元素,它旁边的空格是会保留的.因此图片宽度设置百分百后下面会有点找不出原因的间隙. 解决办法:img{display:block}