Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 奇怪的Spring AOP异常_Java_Xml_Spring_Aop_Aspectj - Fatal编程技术网

Java 奇怪的Spring AOP异常

Java 奇怪的Spring AOP异常,java,xml,spring,aop,aspectj,Java,Xml,Spring,Aop,Aspectj,我正在尝试让我的第一个基于Spring AOP的MethodInterceptors工作,并且在我的超简单XML配置中遇到了一些奇怪的异常 我有一个名为Food的类,它有一个名为eat(ConsumptionRate)的方法,该方法将类型为ConsumptionRate的对象作为其唯一参数;每次调用特定方法(Food::eat(ConsumptionRate))时,我都希望有一个MethodInterceptor来执行“绕过它”: 以下是我的xml配置(aop config.xml)的全部内容:

我正在尝试让我的第一个基于Spring AOP的MethodInterceptors工作,并且在我的超简单XML配置中遇到了一些奇怪的异常

我有一个名为
Food
的类,它有一个名为
eat(ConsumptionRate)
的方法,该方法将类型为
ConsumptionRate
的对象作为其唯一参数;每次调用特定方法(
Food::eat(ConsumptionRate)
)时,我都希望有一个
MethodInterceptor
来执行“绕过它”:

以下是我的xml配置(
aop config.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:aop="http://www.springframework.org/schema/aop"
   xsi:schemaLocation="
   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

<bean name="foodInterceptor" class="com.me.foodproject.core.FoodInterceptor"/>

<aop:config>
    <aop:advisor advice-ref="foodInterceptor"
        pointcut="execution(public * Food.eat(..))"/>
</aop:config>
我唯一的猜测是切入点属性中指定的模式有点错误(可能我需要在其中包含
ConsumptionRate
)。但是这个XML模式的文档几乎找不到,我在这里摸黑

有人有什么建议或者看到什么东西冲着他们跳吗?提前谢谢


作为旁白,如果有人知道某个网站或任何文献记录了所有这些
标签及其属性,请告诉我。已经向我推荐了Spring AOP参考的第6章,尽管这是一个非常全面的教程,但它只是充满了示例,并没有记录整个xml模式。

确保使用完全限定的类名(或也匹配的通配符版本),否则类扫描程序将找不到它。

您不是在寻找模式信息,而是在寻找切入点语法,这在Spring AOP文档中有介绍。有没有没有不带包装的食品类?(好的,对于这个问题,您需要切入点语法:)Hi@Dave-感谢您的回复。当你问“有没有没有没有包的食物类?”时,我可以问你是什么意思吗?一切都编译得非常好,只是在运行时事情变得混乱。我的意思是“有没有没有没有包的食物类?”因为你就是这样定义切入点的。配置文件不会在意是否编译良好——Spring AOP发生在执行时,而不是编译时,与AspectJ.Ahhh不同,我没有使用完全限定的包名。谢谢@Dave,如果你的回答是我会帮你检查的。
<?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:aop="http://www.springframework.org/schema/aop"
   xsi:schemaLocation="
   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

<bean name="foodInterceptor" class="com.me.foodproject.core.FoodInterceptor"/>

<aop:config>
    <aop:advisor advice-ref="foodInterceptor"
        pointcut="execution(public * Food.eat(..))"/>
</aop:config>
java.lang.IllegalArgumentException: warning no match for this type name: Food [Xlint:invalidAbsoluteTypeName]