`

error at ::0 can't find referenced pointcut allMethod

    博客分类:
  • AOP
 
阅读更多
今天在编写AOP代码如下:
package com.zy.spring;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.annotation.Before;

/***
* 定义切面aspect
*
* @author Douglas Lau
*
*/

@Aspect
public class SecurityHandler {

/***
* 定义Pointcut,Pointcut的名称是allMethod,此方法不能有返回值和参数,该方法只是一个标识
*
* Pointcut的内容是一个表达式,描述那些对象的那些方法(订阅Joinpoint)
*/
@Pointcut("execution(* addUser(..))")
private void allMethod() {
}

/***
* 定义Advice,标识在那些切个切入点何处技入此方法
*/
@Before("allMethod()")
//@Before("execution(* addUser(..))")
private void checkSecurity() {
System.out.println("---------安全性检查------------");
}

}
加载运行时总是提示如下错误

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userManager' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut allMethod
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.zy.spring.client.main(client.java:9)
Caused by: java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut allMethod
at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:317)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:195)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:181)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:162)
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:200)
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:254)
at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:286)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1426)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
... 11 more

后来看Spring Recipes Covers Spring Framework 3后调用里边儿的方法又对了,更改后的AOP如下
package com.zy.spring;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.annotation.Before;

/***
* 定义切面aspect
*
* @author Douglas Lau
*
*/

@Aspect
public class SecurityHandler {

/***
* 定义Advice,标识在那些切个切入点何处技入此方法
*/
@Before("execution(* addUser(..))")
private void checkSecurity() {
System.out.println("---------安全性检查------------");
}

}
后成功了,现在还找不到原因何在,目前来说我水平不够!
分享到:
评论
1 楼 zzzhenyu 2012-08-30  
您好,我现在也遇到了同样的问题,请问你后来知道为什么了吗?

相关推荐

    can't find referenced pointcut

    spring-framework-3.1.1.RELEASE jdk1.7 环境下 can't find referenced pointcut 问题解决 换了对应的jar文件即可 aspectjrt.jar aspectj-1.6.6.jar aspectjweaver.jar

    java中的0 can‘t find referenced pointcut runTim

    解决方法 后来经过排查,发现是自己的写法有问题,在@Around的参数中我们使用的是runtime(),这里是有问题的! @Around: 环绕增强,相当于MethodInterceptor. 这里Around的value参数应该写的是上面的签名,而不是...

    aspectjweaver-1.8.9&aspectjrt1;.8.9&aopalliance;-1.0的jar包

    SpringAOP 报错error at ::0 can't find referenced pointcut deleteCell,或类似这样的错误,可能是因为springAOP相关依赖包版本低的缘故,本下载包,可以解决这个问题。

    python UnboundLocalError: local variable ‘x’ referenced before assignment

    一、疑难杂症 def test_scopt(): ...上面这两种情况都会报错:UnboundLocalError: local variable ‘x’ referenced before assignment 二、探究原因 1、python变量作用域   一般在使用函数def、类cla

    aspectj-1.6.6,aspectjrt,aspectjweaver

    spring-framework-3.1.1.RELEASE jdk1.7 环境下can't find referenced pointcut 问题的解决,程序程序无问题的情况下,更换jar文件即可。亲测可用!

    ILSpy_binaries_ILSpy 6.1.zip

    New Language Features C# 9.0: Native ints C# 9.0: Attributes on local functions ...Fix #2068: ILSpy can't find referenced library even though it's open And many other fixes, for a full list click here.

    sunjce_provider.jar

    Could not find class 'com.sun.crypto.provider.SunJCE', referenced from method ...不能加载到类的情况

    [Linker Error] Unresolved external 问题的解决方法

    BCB里遇到过的问题 [Linker Error] Unresolved external 'mysql_init' referenced from C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR.LXSERVER\桌面\TESTINSERTMYSQL\UNIT1.OBJ 的解决方案

    plat-sw-3.0.0.1.zip

    bazel_root/540135163923dd7d5820f3ee4b306b32/external/adv_plat/plat-sw-3.0.0.1.zip: Connection reset and referenced by '//modules/drivers/camera:camera'. ERROR: (12-26 08:52:07.359) Analysis of target ...

    Find Reference 2

    Using FR2 you can then redidrect all those references to a single copy of your choice and safely delete other duplications (usage count of those assets should now be 0) - See all assets not being ...

    Find out Stored Procs Which Referenced Specified TableName

    Find out Stored Procs Which Referenced Specified TableName

    comsupp.lib源码

    _com_issue_error@@YAXJ@Z) referenced in function "public: __thiscall _variant_t::_variant_t(unsigned short const *)" (??0_variant_t@@QAE@PBG@Z) 的提示,此时需要在project-setting-link中加入comsupp,lib...

    [Linker Error] Unresolved external 'viOpen' referenced from

    [Linker Error] Unresolved external 'viOpen' referenced from 这种错误的解决方法

    Find Reference 2 1.2.10

    Using FR2 you can then redidrect all those references to a single copy of your choice and safely delete other duplications (usage count of those assets should now be 0) - See all assets not being ...

    stm32f4标准库C++与C混合开发工程

    用C++对stm32的标准库进行开发,包括完整的重定向printf,解决.axf: Error: L6915E: Library reports error: __use_no_semihosting was requested, but _sys_open was referenced以及Error: L6200E:symbol__stdout ...

    完整jar包资源,COULD NOT FIND stream,包缺失使用

    打包找不到 stream COULD NOT FIND stream-2.5.2 解压后将jar包与pom文件都放在.m2\repository指定路径下

    修复Linux异常自动重启问题

    这几天训网络最困扰我的问题就是服务器...EXT4-fs error (device sda1): ext4_lookup:1593: inode #6004222: comm trash-expunge: deleted inode referenced: 6004301 类似这样的错误,看样子是sda1磁盘文件系统的问题

    M4M v2.1.1 Host Interface API - org.mifare4mobile.hostinterface - 2.2.zip

    AID: 0xA0:0x0:0x0:0x3:0x96:0x4D:0x34:0x4D:0x30 Version: 2.2 Set of documents referenced in this package: 昜VC Creation] - MIFARE Virtual Card Creation v1.0.2 昜VC Management] - MIFARE Virtual Card...

    反编译软件reflector软件,超好用

    You can then open Visual Studio, and use the .NET Reflector menu to select referenced assemblies you would like to debug into. These assemblies are then decompiled to C# or VB. You can then step into ...

    Foundations of PEAR_ Rapid PHP Development.pdf

    The Windows installer doesn’t include the go-pear.bat script referenced here to begin the installation of PEAR. After extracting the PHP from the ZIP archive, the first step is to execute the go-...

Global site tag (gtag.js) - Google Analytics