引入AOP 报错 error at ::0 formal unbound in pointcut
使用了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的更多相关文章
- springAOP配置XML方式配置切面报错error at ::0 formal unbound in pointcut
[错误配置文件] <aop:config> <aop:pointcut expression="execution(* net.fifteenho.service.impl ...
- Spring: aop自动标注时出现 “0 formal unbound in pointcut"
异常代码信息: org.springframework.beans.factory.BeanCreationException: Error creating bean with name forma ...
- spring异常-aoperror at :0 formal unbound in pointcut
八月 17, 2016 10:15:21 上午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRe ...
- 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 ...
- 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.一看我以为注解写错了,结果通过查询相关资 ...
- Spring AOP报错
八月 01, 2016 10:08:48 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRe ...
- vue2.0+按需引入element-ui报错
项目使用vue脚手架自动生成的,vue版本为^2.5.16.项目中需要按需使用element-ui,根据element-ui的官方文档,一开始在babel.config.js文件中修改配置 modul ...
- 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: 问题原因: ...
- wince6.0 编译报错:"error C2220: warning treated as error - no 'object' file generated"的解决办法
内容提要:wince6.0编译报错:"error C2220: warning treated as error - no 'object' file generated" 原因是 ...
随机推荐
- 用ccproxy + stunnel做个加密代理
https://www.stunnel.org/downloads.html ccproxy + stunnel做个加密http代理和socks5代理 目前国内用户无法访问某些国外网站,如http:/ ...
- HTML DOM 属性 对象
HTML DOM 属性 对象 HTML DOM 节点 在 HTML DOM (Document Object Model) 中, 所有的都是 节点: 文档是文档节点 所有 HTML 元素是元素节点 所 ...
- CGPoint、CGSize、CGRect and UIView
首先要弄懂几个基本的概念. 一)三个结构体:CGPoint.CGSize.CGRect 1. CGPoint /* Points. */ struct CGPoint { CGFloat x; CGF ...
- PAT 1015. 德才论 (25)
宋代史学家司马光在<资治通鉴>中有一段著名的"德才论":"是故才德全尽谓之圣人,才德兼亡谓之愚人,德胜才谓之君子,才胜德谓之小人.凡取人之术,苟不得圣人,君子 ...
- 您的项目引用了最新实体框架;但是,找不到数据链接所需的与版本兼容的实体框架数据库 EF6使用Mysql的技巧
转载至: http://www.cnblogs.com/Imaigne/p/4153397.html 您的项目引用了最新实体框架:但是,找不到数据链接所需的与版本兼容的实体框架数据库 EF6使用Mys ...
- [py]给函数传递数组和字典
一 , 1.1传元组 def fun(x): print x t=(1,2) fun(t) 1.2传元组 #传元组 def fun(x,y): print x,y # t=(1,2) t=(1,2,3 ...
- Session一次错误记录
/// <summary> /// 验证登录状态是否已失效 /// </summary> /// <returns>< ...
- hadoop1.2.1伪分布模式配置
1.修改core-site.xml,配置hdfs <configuration> <property> <name>fs.default.name</name ...
- 【LeetCode】95. Unique Binary Search Trees II
Unique Binary Search Trees II Given n, generate all structurally unique BST's (binary search trees) ...
- dev gridcontrol纵向合并单元格设置
1.要设置gridcontrol中指定列(columns中选中指定列)的AllowMerge属性为true; 2.要设置gridview中AllowCellMerge的属性为true; 3.如果只合并 ...