使用了AOP 后启动报错

九月 27, 2016 2:29:46 下午 org.springframework.context.support.AbstractApplicationContext refresh
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'acAction': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountService' defined in file [D:\workspace_eclipse_mars\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\bpmp\WEB-INF\classes\com\bkc\bpmp\xdj\zc\service\impl\AccountServiceImpl.class]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
九月 27, 2016 2:29:46 下午 org.springframework.web.servlet.FrameworkServlet initServletBean
严重: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'acAction': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountService' defined in file [D:\workspace_eclipse_mars\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\bpmp\WEB-INF\classes\com\bkc\bpmp\xdj\zc\service\impl\AccountServiceImpl.class]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1208)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)

  

在使用声明方式的AOP编程中,遇到以下问题,解决方法如下:

(1)error at ::0 formal unbound in pointcut

解决方法:去掉函数通知函数中的参数,比如:将

@Before("execution(public void com.bjsxt.dao.impl.UserDAOImpl.*(..))")

public void beforeMethod(Method method){

System.out.println("method before");

}

改为

@Before("execution(public void com.bjsxt.dao.impl.UserDAOImpl.*(..))")

public void beforeMethod(){

System.out.println("method before");

}

情况二:

原写法:

@Before("@annotation(org.haha.web.annotation.BrowAuth)
public void beforeExec(HttpServletRequest request) {

......

}

会报以下错误:

0 formal unbound in pointcut

原因是应该用args指明参数,改成以下就可以了:

@Before("@annotation(org.haha.web.annotation.BrowAuth) && (args(request,..) || args(..,request))")
public void beforeExec(HttpServletRequest request) {

......

}

方法中未带参数,本bug 非此原因

(2)可能原因(我的猜测,未确认)

  使用了AOP 之后(spring),实现注解是采用代理的方式,而代理有两种jdk自带代理和 cglib,而在springmvc 中直接使用自动注解的时候,没有使用这一层代理。接口、接口的实现类,其注解的命名方式不一致,造成了自动注入的时候,代理不知道该选择哪一个类……

  可解决方法:一、使用AOP注解,将原有的业务上的接口、接口实现类的命名改统一。假设接口为 IUserDao,实现类为 UserDaoImpl ,自动注入的时候写成  IUserDao userDaoImpl  (原因:不清楚)

    方法二、不要使用AOP注解,在xml 中配置需要的AOP 方式,如下:自定义LoggingInterceptor 中有个around 方法

    

<bean id="loggingInterceptor" class="com.bkc.core.aspectj.LoggingInterceptor" />	
  <aop:config>
<aop:aspect id="loggingAspect" ref="loggingInterceptor">
<aop:pointcut id="loggingIn" expression="execution(* com.bkc.oa.controller..*.*(..))" />
<!--
<aop:before method="before" pointcut-ref="loggingIn"/>
<aop:after method="after" pointcut-ref="loggingIn"/> -->
<aop:around method="around" pointcut-ref="loggingIn"/>
</aop:aspect>
</aop:config>

  

引入AOP 报错 error at ::0 formal unbound in pointcut的更多相关文章

  1. springAOP配置XML方式配置切面报错error at ::0 formal unbound in pointcut

    [错误配置文件] <aop:config> <aop:pointcut expression="execution(* net.fifteenho.service.impl ...

  2. Spring: aop自动标注时出现 “0 formal unbound in pointcut"

    异常代码信息: org.springframework.beans.factory.BeanCreationException: Error creating bean with name forma ...

  3. spring异常-aoperror at :0 formal unbound in pointcut

    八月 17, 2016 10:15:21 上午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRe ...

  4. springAOP注解方式定义切入点报错error at ::0 can't find referenced pointcut

    [说明] 1.使用spring版本:4.0.4 2.springAOP相关依赖包: 1)aopalliance-1.0.jar 2)aspectjweaver-1.8.9.jar 3)aspectjr ...

  5. Java入门到精通——调错篇之Spring2.5利用aspect实现AOP时报错: error at ::0 can't find referenced pointcut XXX

    一.问题描述及原因. 利用Aspect注解实现AOP的时候出现了error at ::0 can't find referenced pointcut XXX.一看我以为注解写错了,结果通过查询相关资 ...

  6. Spring AOP报错

    八月 01, 2016 10:08:48 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRe ...

  7. vue2.0+按需引入element-ui报错

    项目使用vue脚手架自动生成的,vue版本为^2.5.16.项目中需要按需使用element-ui,根据element-ui的官方文档,一开始在babel.config.js文件中修改配置 modul ...

  8. android sdk启动报错error: could not install *smartsocket* listener: cannot bind to 127.0.0.1:5037:

    android sdk启动报错error: could not install *smartsocket* listener: cannot bind to 127.0.0.1:5037: 问题原因: ...

  9. wince6.0 编译报错:"error C2220: warning treated as error - no 'object' file generated"的解决办法

    内容提要:wince6.0编译报错:"error C2220: warning treated as error - no 'object' file generated" 原因是 ...

随机推荐

  1. NVIDIA显卡设置

    在玩3D游戏时,因为我的显卡不是特别给力,所以针对性能做出牺牲质量换取性能的调整. 简单设置 简单的方法是,3D设置-通过预览调整图像设置,根据偏重点来设置平衡:性能或者质量. 高级设置 如果你想自行 ...

  2. JAVA中的单利

    单列:单例模式分三种:懒汉式单例.饿汉式单例.登记式单例三种.单例模式有一下特点:1.单例类只能有一个实例.2.单例类必须自己自己创建自己的唯一实例.3.单例类必须给所有其他对象提供这一实例. 一.懒 ...

  3. flexslider.js和waypoints.js一起用时的巨坑

    Flexslider has a callback API where you can execute functions after various actions:https://github.c ...

  4. UIScrollView解决无法触发手势

    //创建一个分类 //.h #import <UIKit/UIKit.h> @interface UIScrollView (Touch) - (void)touchesBegan:(NS ...

  5. iOS多线程之NSThread详解

    在iOS中每个进程启动后都会建立一个主线程(UI线程),这个线程是其他线程的父线程.由于iOS中除了主线程,其他子线程是独立于Cocoa Touch的,所以只有主线程可以更新UI界面.iOS多线程的使 ...

  6. mysql连接数设置操作(Too many connections)

    mysql在使用过程中,发现连接数超了~~~~ [root@linux-node1 ~]# mysql -u glance -h 192.168.1.17 -pEnter password: ERRO ...

  7. 一种Docker image镜像的取代方案

    在http://openvz.org/Download/templates/precreated中有很多压缩的镜像文件,可以将这些文件下载后采用import方式使用镜像,也可以采用我原来的博文:doc ...

  8. php碎片

    1.flock LOCK_EX 独占锁定 LOCK_SH 共享锁定 LOCK_UN 解除锁定 LOCK_NB 锁定但不堵塞进程,直接返回false 2. fseek SEEK_CUR SEEK_END ...

  9. 截取视图某一段另存为部分视图(Partial View)

    在做ASP.NET MVC后台管理程序时,根据程序需要,Isus.NET需要实现一个功能,就是动态截取视图某一段另存为部分视图Partial View. 思路为在视图中,使用jQury的程序截图以及P ...

  10. silverlight: http请求的GET及POST示例

    http请求的get/post并不是难事,只是silverlight中一切皆是异步,所以代码看起来就显得有些冗长了,下面这个HttpHelper是在总结 园友 的基础上,修改得来: namespace ...