Java ee修炼之路:第一次使用Spring aop出现错误

来源:互联网 发布:淘宝好评80字以上 编辑:程序博客网 时间:2024/06/05 06:08

错误控制台输出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无法匹配到方法

0 0