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

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

问题描述

我有以下方面:

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);        
    }

}

以及以下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/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.

我非常傻眼,因为我很确定此配置之前能正常工作.更重要的是,这是一个Spring Roo项目,因此所有AspectJ配置都应该没问题.

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.

任何人都可以帮忙吗?

推荐答案

这可能是因为您的方面由于某种原因未编译,您是否可以尝试为AspectJ Weaver插件添加更多诊断信息,并查看打印在控制台,方法如下:

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>

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

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天全站免登陆