Error creating bean with name 'org.springframework.context.annotation.internalRequiredAnnotationProc

本文探讨了Spring AOP中配置和注解使用不当导致的问题,并给出了具体的错误示例与修正方案,帮助读者理解正确配置切入点表达式的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

异常信息: xml 文件配置注解时报错

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.annotation.internalRequiredAnnotationProcessor': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJPointcutAdvisor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: cn.itcast.service.imple.AopServiceBean3 [Xlint:invalidAbsoluteTypeName]

原因:

applicatonContext.xml

<aop:config>
<aop:aspect id="asp" ref="myInterceptor1">
<!--<aop:pointcut id="mycut" expression="execution(* cn.itcast.service.imple.AopServiceBean3..*(..))" />--> 正确的

<!--<aop:pointcut id="mycut" expression="execution(* cn.itcast.service.imple.AopServiceBean3.*.*(..))" />-->正确的
<aop:pointcut id="mycut" expression="execution(* cn.itcast.service.imple.AopServiceBean3..*.*(..))" />正确的
<!--下面的配置有问题AopServiceBean3.*(..)-->
<!--<aop:pointcut id="mycut" expression="execution(* cn.itcast.service.imple.AopServiceBean3.*(..))" />-->错误的
<aop:before method="doAccessCheck" pointcut-ref="mycut"/>
</aop:aspect>

如用注解:

@Pointcut("execution (* cn.itcast.aop.service.imple..*.*(..))") //imple包下所有类的所有方法进行拦截
//@Pointcut("execution (* cn.itcast.aop.service.imple.AopServiceBean2.*(..))")只对AopServiceBean2类下方法进行拦截

有一个问题没有搞明白:为什么注解和配置一样会报错?

annotation:::::::<!--<aop:pointcut id="mycut" expression="execution(* cn.itcast.service.imple.AopServiceBean3.*(..))" />-->错误的

xml:::::::::::::::::::://@Pointcut("execution (* cn.itcast.aop.service.imple.AopServiceBean2.*(..))")只对AopServiceBean2类下方法进行拦截 正确的

参考文章:

http://hi.baidu.com/gglzf4/blog/item/424bd5d761d23b2006088b1b.html

http://blog.youkuaiyun.com/sustbeckham/article/details/5819213

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值