0

Spring チュートリアル 28 - ポイントカットとワイルドカード式を練習する と、次の問題が発生します。

スレッド "main" org.springframework.beans.factory.BeanCreationException での例外:
クラスパス リソースで定義された名前が「triangle」の Bean の作成中にエラーが発生しました
[springPointcuts.xml]: Bean の初期化に失敗しました。ネストされた例外は
java.lang.IllegalArgumentException: ::0 でエラーが発生し、参照先が見つかりません
pointcut allGetters

以下に私のコードが表示されます。私の問題に対する解決策をいただければ幸いです。

LoggingAspectPointcuts :

package org.koushik.javabrains.aspect;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class LoggingAspectPointcuts {

    @Before("allGetters()")
    public void LoggingAdvice(){
    System.out.println("Advice run.Get Method called");
    }

    @Before("allGetters()")
    public void secondAdvice() {
    System.out.println("Second Advice executed ");
    }

    @Pointcut("execution(* get*())")
    public void allGetters(){}


}

AopMainWildCardPointcuts :

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import org.koushik.javabrains.service.ShapeService;

public class AopMainWildCardPointcuts {

    public static void main(String[] args) {


        ApplicationContext ctx = new ClassPathXmlApplicationContext("springPointcuts.xml");

        ShapeService shapeService= (ShapeService) ctx.getBean("shapeService");
        System.out.println(shapeService.getCircle().getName());



    }

springPointcuts.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"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
    <aop:aspectj-autoproxy/>
    <bean name="triangle" class="org.koushik.javabrains.model.Triangle">
    <property name="name" value="Triangle Name"/>
    </bean>
    <bean name="circle"   class="org.koushik.javabrains.model.Circle">
    <property name="name" value="Circle Name"/>
    </bean> 

    <bean name="loggingAspectPointcuts" class="org.koushik.javabrains.aspect.LoggingAspectPointcuts"/>

</beans> 
4

3 に答える 3

1

私はあなたがaspectjrtとaspectjweaver jarsの1.5バージョンを使用している可能性があると思います.1.6バージョンのいずれかを使用すると、それが動作します

于 2013-01-31T05:35:12.147 に答える
0

交換....

<aop:aspectj-autoproxy/>

と ...

<aop:aspectj-autoproxy>
     <aop:include name="loggingAspectPointcuts"/>
</aop:aspectj-autoproxy>
于 2013-01-21T03:11:56.723 に答える
0

正しいバージョンの cglib.jar を使用してみてください。正しいバージョン 2.1_3 または最新のものを使用してください。

asm-3.3.1
cglib-2.2.2
aspectjrt-1.6.11
aspectweaver-1.6.11.

必ず上記の jar を使用してください。

于 2017-12-19T02:01:59.280 に答える