`

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相关依赖包版本低的缘故,本下载包,可以解决这个问题。

    aspectj-1.6.6,aspectjrt,aspectjweaver

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

    python UnboundLocalError: local variable ‘x’ referenced before assignment

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

    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.

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

    根据提供的文件信息,开发者在使用Borland C++ Builder (BCB) 开发环境时遇到了一个典型的链接错误:“[Linker Error] Unresolved external 'mysql_init' referenced from C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR....

    [Linker Error] Unresolved external 'viOpen' referenced from

    具体到本案例中的 “Unresolved external ‘viOpen’ referenced from” 错误,表示编译器在链接时未能找到 `viOpen` 函数的定义。 #### 三、分析错误来源 根据提供的错误日志,可以看出错误发生在以下几个方面: ...

    提示出现unresolved external symbol _main的解决方法

    libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16 msvcrtd.lib(crt

    sunjce_provider.jar

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

    ICSharpCode.SharpZipLib Version=0.86.0.518

    这个库在版本0.86.0.518中被验证为功能正常,用户可以放心将其集成到自己的项目中,以实现对压缩文件的支持。 一、SharpZipLib简介 SharpZipLib,又被称为“SharpZlib”或“#ziplib”,是由ICSharpCode开发的,它...

    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 ...

    AndroidSupportAnnotaitons

    android.support.annotation.* 找不到的问题,

    keil 中常见的几种警告

    3. Error: Can’t open file ‘beep.h’ 这个错误发生在编译过程中,因为找不到#include指令指定的头文件'beep.h'。解决方法是创建一个'beep.h'文件并将其放在指定的工作目录中。 4. Error 237: 'LedOn': function ...

    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 ...

    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...

    IAR编译错误总结[整理].pdf

    Error[Li005]: no definition for "__program_start" [referenced from F:\sd\WORM_SD_MMC1\WORM_SD_MMC\Debug\Obj\stm32f10x_vector.o] ``` **解决方法**: - **检查符号定义**:确保符号“__program_start”已被...

    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

    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 ...

Global site tag (gtag.js) - Google Analytics