【问题标题】:Spring AOP pointcut is not well formedSpring AOP 切入点没有很好地形成
【发布时间】:2011-08-20 00:27:21
【问题描述】:

线程“main”中的异常 org.springframework.beans.factory.BeanCreationException:错误 用名字创建bean 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException: 不能 实例化 bean 类 [org.springframework.aop.aspectj.AspectJPointcutAdvisor]:构造函数 抛出异常;嵌套异常是 java.lang.IllegalArgumentException:切入点格式不正确: 在字符位置 49 处期待“名称模式” 执行(*com.idol.performers.Performer.perform(..)

我的切入点有什么问题?书中说

(..) // means taking any arguments

我的 xml:

 ...
<aop:before pointcut="execution(*com.idol.performers.Performer.perform(..))" method="takeSeats"/>
 ...

【问题讨论】:

    标签: spring aop spring-aop pointcut


    【解决方案1】:

    试试这个:

    <aop:before pointcut="execution(* com.idol.performers.Performer.perform(..))" method="takeSeats"/>
    

    问题是*com.idol.performers.Performer.perform(..) 之间没有空格

    【讨论】:

    • 有时解析错误会导致消息晦涩难懂。在这种情况下,它认为* 通配符是com.idol.performers.Performer.perform 的一部分,这意味着它期望该类型作为返回类型,而不仅仅是*。然后它建议在它看到“(”之前,它需要有一个表示方法名称的“名称模式”。这就是为什么空格是必要的,这就是它真正想要说的最好的方式可以。
    【解决方案2】:

    *和com.idol.performers.Performer.perform(..)之间应该有空格

    【讨论】:

      猜你喜欢
      • 2014-12-14
      • 2019-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多