このサイトで簡単なaopの例を実行してみます。私は春のaopとaspectj、aspectjweaverjarを持っています:
@Aspect
public class StringAspect {
@Pointcut("call(* String.toLowerCase())")
public void toLowerCasePointcut() {}
@Around("toLowerCasePointcut()")
public String toLowerCaseAroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable {
String text = ((String) joinPoint.getTarget()).toUpperCase();
return text;
}
}
この例を"AaBbCc".toLowerCase()のようにTest.javaで実行すると、この例外が発生します。
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean ... Initialization of bean failed; nested exception is org.aspectj.weaver.tools.UnsupportedPointcutPrimitiveException: Pointcut expression call(* String.toLowerCase()) contains unsupported pointcut primitive 'call'
Spring AOPには「呼び出し」が含まれていませんが、アスペクト指向ウィービングが機能しないのはなぜですか、アイデアはありますか?ありがとうございました。
編集:
私の春の設定ファイルには、@aspect注釈付きクラスとのBean定義しかありません<aop:aspectj-autoproxy />
。私のjarファイルは次のとおりです:spring-aop-3.0.5、aopalliance、aspectjrt1.6.8、aspectjweaver1.5.0