错误控制台输出Caused by: java.lang.IllegalArgumentException: warning no match for this type name: com.book [Xlint:invalidAbsoluteTypeName]
xml文件如下
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<bean id="book" class="com.book.Book"></bean>
<bean id="mybook" class="com.book.Mybook"></bean>
<aop:config >
<aop:pointcut expression="execution(* com.book.*(..))" id="pointcut1"/>
<aop:aspect ref="mybook">
<aop:before method="before1" pointcut-ref="pointcut1"/>
</aop:aspect>
</aop:config>
</beans>
后来查了下,原因是
<aop:pointcut expression="execution(* com.book.*(..))" id="pointcut1"/>
写错了,正确写法应该是
<aop:pointcut expression="execution(* com.book.*.*(..))" id="pointcut1"/>
写漏了 .*导致spring无法匹配到方法
本文详细解析了Spring AOP配置中出现的一个常见错误,并给出了正确的配置示例。具体介绍了如何修正pointcut表达式来确保切面能够正确地匹配目标方法。
168万+

被折叠的 条评论
为什么被折叠?



