天天看点

Spring报nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in point

在我们使用spring注解方式写通知时,例如
@AfterReturning(value = "pointcut()")
    public void after(JoinPoint jp,Object returningValue){
        System.out.println("注解方式实现【后置通知】"+
                jp.getSignature().getName()+"目标对象:"+
                jp.getTarget()+","+"参数的返回值:"+returningValue);
    }
           

Object returningValue是后置通知直接 得到返回值,这个使用时是特别的方便,但是用这样的方式做业务会报:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘studentDaoImpl’ defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)

at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)

at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)

我们的解决方式为:

Spring报nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in point

在方法中声明一下就可以了:

Spring报nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in point