Spring 获取java.lang.IllegalArgumentException的原因:错误位于::0无法找到引用的切入点getLogging

Spring 获取java.lang.IllegalArgumentException的原因:错误位于::0无法找到引用的切入点getLogging,spring,aop,spring-aop,Spring,Aop,Spring Aop,我在标题上得到了这个例外。我给出以下代码: @Component("student") public class Student { private String name; private int age; public String getName() { return name; } public void setName(String name) { this.name = name; } p

我在标题上得到了这个例外。我给出以下代码:

@Component("student")
public class Student {

    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void printSomething() {
//        get logging with aop
        System.out.println("student printed something");
//        get logging with aop
    }
}

@Aspect
@Component
public class StudentLogging {

    private final static Logger logger = Logger.getLogger(StudentLogging.class.getName());

    @Pointcut("execution(* aspectorientedprog.aopexample.Student.printSomething(..))")
    private void getLogging() {

    }

    @Around("getLogging()")
    public String aroundPrintSomething(ProceedingJoinPoint joinPoint) throws Throwable {
        logger.info("before printing something");
        Object o = joinPoint.proceed();
        logger.info("after printing something");
        return o.toString();
    }

}

public class AspectStudentTest {

    @Test
    public void aspect_student_test() {
        ApplicationContext context = new ClassPathXmlApplicationContext("aspect/aspect-conf.xml");
        Student student = context.getBean("student", Student.class);
        student.printSomething();
        System.out.println();
    }

}
我的配置文件:

<context:annotation-config/>
<context:component-scan base-package="aspectorientedprog"/>
<aop:aspectj-autoproxy/>
我研究了一些关于这个错误的东西,但是所有的解决方案都不起作用,它是关于AOP版本的。如果我只用

@环形执行类

这是真正的工作,但如果我像上面一样使用@Pointcut和@Around,我会遇到这个问题

感谢您的回答

尝试:

@Pointcut("execution(* aspectorientedprog.aopexample.Student.printSomething(..))")
    public void getLogging() {

    }

不使用公共访问修饰符,我们已经用private阻止对@Pointcut-mothod的访问