简体   繁体   English

"未调用 JdbcOperations 中使用的 Spring AOP 方面"

[英]Spring AOP Aspect used in JdbcOperations not invoked

Your aop expression is defined as a pointcut to a JdbcOperation.* which is an interface, and interface calls are not advised. 您的aop表达式被定义为JdbcOperation的切入点。*这是一个接口,并且不建议接口调用。

AspectJ can intercept pointcuts in the spring framework for spring-managed-beans. AspectJ可以在Spring框架中拦截spring-managed-beans的切入点。 If the bean is not spring managed you'll need to manually register it using ProxyFactoryBean/ProxyFactory for advisal. 如果bean不是spring管理的,你需要使用ProxyFactoryBean / ProxyFactory手动注册它以获取建议。 In your case you already have a bean implementing the JdbcOperations interface registered in your spring application-context. 在您的情况下,您已经有一个bean实现了在spring应用程序上下文中注册的JdbcOperations接口。

As per your problem changing the pointcut to use any implementation of the JdbcOperations interface ( the jdbcTemplate bean definition ) should solve your problem. 根据您的问题,更改切入点以使用JdbcOperations接口的任何实现( jdbcTemplate bean定义)应该可以解决您的问题。

For example 例如

@Before("execution(* org.springframework.jdbc.core.JdbcOperations+.*(..))")

you lost 1 .* in the expression,it should be你失去了 1 .*在表达式中,它应该是

// this works fine 
@Before("execution(* org.springframework.jdbc.core..*JdbcOperations.*(String, ..))") 

But you wrote like但是你写的像

// this's not good 
@Before("execution(* org.springframework.jdbc.core.JdbcOperations.*(..))") 

This answer came to me unexpectedly when I saw this ,link here https://stackoverflow.com/questions/58282255/how-to-intercept-jdbctemplate-whose-instance-is-created-by-myself当我看到这个答案时,这个答案意外地出现了,链接在这里https://stackoverflow.com/questions/58282255/how-to-intercept-jdbctemplate-whose-instance-is-created-by-myself

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM