找不到匹配的工厂方法:工厂方法“aspectOf()" [英] No matching factory method found: factory method 'aspectOf()'

查看:46
本文介绍了找不到匹配的工厂方法:工厂方法“aspectOf()"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下方面:

package trc.suivi.aspects;导入 java.util.Date;导入 org.apache.log4j.Logger;导入 org.springframework.beans.factory.annotation.Autowired;导入 trc.suivi.domain.EvenementPli;导入 trc.suivi.domain.Pli;导入 trc.suivi.domain.TypeEvement;导入 trc.suivi.repository.EvenementPliRepository;公共方面 PliEventManagerAspect {私有静态最终记录器日志 = Logger.getLogger(PliEventManagerAspect.class);@自动连线私人 EvenementPliRepository EvenementPliRepository;公共 PliEventManagerAspect() {}切入点 catchEMPersist(Pli pli) : (execution(* trc.suivi.repository.PliRepository+.save(*)) && args(pli));切入点 catchEMPersist() : (execution(trc.suivi.domain.Pli.persist()));after(Pli pli) 返回:catchEMPersist(pli) {log.debug("catchEMPersist(pli)");EvenementPli ev = new EvenementPli();ev.setDateCreation(new Date());ev.setType(TypeEvement.creation);ev.setMessage("Création d'un pli");EvenementPliRepository.save(ev);}after() 返回:catchEMPersist() {log.debug("catchEMPersist()");EvenementPli ev = new EvenementPli();ev.setDateCreation(new Date());ev.setType(TypeEvement.creation);ev.setMessage("Création d'un pli");EvenementPliRepository.save(ev);}}

以及以下 xml 配置:

<aop:aspectj-autoproxy/><bean class="trc.suivi.aspects.PliEventManagerAspect" factory-method="aspectOf"/></豆类>

当我启动我的应用时,我得到这个:

未找到匹配的工厂方法:工厂方法aspectOf()".检查具有指定名称的方法是否存在并且它是静态的.

我很傻,因为我很确定这个配置以前运行良好.更重要的是,这是一个 Spring Roo 项目,所以所有的 aspectJ 配置都应该没问题.

有人可以帮忙吗?

解决方案

这可能是因为无论出于何种原因您的方面尚未编译,您可以尝试向您的 aspectj weaver 插件添加更多诊断信息,并查看正在打印的内容控制台,沿着这些路线:

<预><代码><配置><outxml>true</outxml><showWeaveInfo>false</showWeaveInfo><Xlint>警告</Xlint><详细>真</详细>...</配置>

此外,由于您使用的是原始 aspectj,因此您实际上并不需要使用 <aop:aspectj-autoproxy/> 来触发 Spring AOP.

I have the following aspect:

package trc.suivi.aspects;

import java.util.Date;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import trc.suivi.domain.EvenementPli;
import trc.suivi.domain.Pli;
import trc.suivi.domain.TypeEvenement;
import trc.suivi.repository.EvenementPliRepository;

public aspect PliEventManagerAspect {

    private static final Logger log = Logger.getLogger(PliEventManagerAspect.class);

    @Autowired
    private EvenementPliRepository evenementPliRepository;

    public PliEventManagerAspect() {
    }

    pointcut catchEMPersist(Pli pli) : (execution(* trc.suivi.repository.PliRepository+.save(*)) && args(pli));
    pointcut catchEMPersist() : (execution(trc.suivi.domain.Pli.persist()));

    after(Pli pli) returning: catchEMPersist(pli) {
        log.debug("catchEMPersist(pli)");
        EvenementPli ev = new EvenementPli();
        ev.setDateCreation(new Date());
        ev.setType(TypeEvenement.creation);
        ev.setMessage("Création d'un pli");
        evenementPliRepository.save(ev);        
    }

    after() returning: catchEMPersist() {
        log.debug("catchEMPersist()");
        EvenementPli ev = new EvenementPli();
        ev.setDateCreation(new Date());
        ev.setType(TypeEvenement.creation);
        ev.setMessage("Création d'un pli");
        evenementPliRepository.save(ev);        
    }

}

And the following xml config:

<?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/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
    <aop:aspectj-autoproxy />
    <bean class="trc.suivi.aspects.PliEventManagerAspect" factory-method="aspectOf"/>
 </beans>

When I start my app, I get this:

No matching factory method found: factory method 'aspectOf()'. Check that a method with the specified name exists and that it is static.

I am quite dumbfounded as I am pretty sure this config worked fine before. What is more this is a Spring Roo project so all the aspectJ config should be fine.

Can anyone please help?

解决方案

This is probably because your aspect has not compiled for whatever reason, can you try and add more diagnostic to your aspectj weaver plugin and see what is being printed on the console, along these lines:

<configuration>
    <outxml>true</outxml>
    <showWeaveInfo>false</showWeaveInfo>
    <Xlint>warning</Xlint>
    <verbose>true</verbose>
                ...
</configuration>

Also since you are using raw aspectj you don't really need to use <aop:aspectj-autoproxy/> which is used to trigger Spring AOP.

这篇关于找不到匹配的工厂方法:工厂方法“aspectOf()"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆