gpt4 book ai didi

spring - java.lang.IllegalArgumentException: error at::0 切入点中的正式未绑定(bind)

转载 作者:IT老高 更新时间:2023-10-28 13:50:00 27 4
gpt4 key购买 nike

Thinker.java

package springdemo2;

public interface Thinker {
void thinkOfSomething(String thoughts);
}

Volunteer.java

package springdemo2;

public class Volunteer implements Thinker{
private String thoughts;

@Override
public void thinkOfSomething(String thoughts) {
this.thoughts=thoughts;
}

public String getThoughts(){
return thoughts;
}
}

MindReader.java

package springdemo2;

public interface MindReader {
void interceptThoughts(String thoughts);

String getThoughts();
}

Magician.java

package springdemo2;

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

@Aspect
public class Magician implements MindReader {

private String thoughts;

@Pointcut("execution(* springdemo2."
+ "Thinker.thinkOfSomething(String)) and args(thoughts)")
public void thinking(String thoughts){
}

@Override
@Before("thinking(thoughts)")
public void interceptThoughts(String thoughts) {
this.thoughts=thoughts;
System.out.println("Advice method intercepted Thoughts..."+thoughts);
}

@Override
public String getThoughts() {
return thoughts;
}
}

XML( Spring )

我已包含 <aop:aspectj-autoproxy/>在我的 XML 文件中。

我收到以下错误消息

 java.lang.IllegalArgumentException: error at ::0 formal unbound in
pointcut

最佳答案

@Pointcut("execution(* springdemo2."
+ "Thinker.thinkOfSomething(String)) and args(thoughts)")

应该是

@Pointcut("execution(* springdemo2."
+ "Thinker.thinkOfSomething()) && args(thoughts)")

关于spring - java.lang.IllegalArgumentException: error at::0 切入点中的正式未绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8232339/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com