Partage
  • Partager sur Facebook
  • Partager sur Twitter

AOP, aspectjweaver et spring

exception

Anonyme
    18 juin 2009 à 17:50:31

    Salut,

    je souhaite rajouter le système d'aspect à mon application. Cependant j'ai un petit problème.
    Quand je lance mon application j'ai l'erreur suivante :
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mainService': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 can't make static reference to abstract pointcut

    Voilà mon fichier 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"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:util="http://www.springframework.org/schema/util"
    	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.xsd
    		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
    		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
    
    	<aop:aspectj-autoproxy />
    	<context:annotation-config />
    	<context:component-scan base-package="com.application.service" />
    	
    	<bean id="tracerAdvice" class="com.application.SysoutInterceptor" />
    	
    </beans>
    


    ma de pointcut :
    package com.application;
    
    import org.aspectj.lang.annotation.Aspect;
    import org.aspectj.lang.annotation.Pointcut;
    
    @Aspect
    public interface SysoutAspect {
    
    	@Pointcut("execution(* com.application.service.impl.*Service.*(..))")
    	void logPointcut();
    
    }
    


    mon advice :
    package com.application;
    
    import org.aspectj.lang.ProceedingJoinPoint;
    import org.aspectj.lang.annotation.Around;
    import org.aspectj.lang.annotation.Aspect;
    
    @Aspect
    public class SysoutInterceptor {
    	
    	@Around("com.application.SysoutAspect.logPointcut()")
    	public void doLog(ProceedingJoinPoint point) throws Throwable {
    		System.out.println("Bonjour tu vas bien ?");
    	}
    	
    }
    


    • Partager sur Facebook
    • Partager sur Twitter

    AOP, aspectjweaver et spring

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown