我有一个从应用程序上下文获得的ShapeService。 shapeService注入了一个Circle和Triangle。我的shapeService中有getCircle()和getTriangle()。我也有一个建议,配置为每当调用getter时触发。指定的切入点表达式使其适用于所有获取者。所以每当getCircle()或getTriangle()被调用时,都会触发建议。但我想知道为什么没有为applicationContext.getBean()触发。这也是一个满足切入点表达式的getter。任何人都可以帮我找出为什么它没有被触发。getBean()没有被触发的AOP通配符
@Aspect
@Component
public class LoggingAspect {
@Before("allGetters()")
public void loggingAdvice(JoinPoint joinPoint){
System.out.println(joinPoint.getTarget());
}
@Pointcut("execution(public * get*(..))")
public void allGetters(){}
}
这是获取bean的主要类。只有Shapeservice的getter和圆形的吸气剂得到触发,而不是apllicationContext的的getBean
public class AopMain {
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("spring-config.xml");
ShapeService shapeService = ctx.getBean("shapeService", ShapeService.class);
System.out.println(shapeService.getCircle().getName());
}
}
感谢