java – 为什么Spring AOP不拦截受保护的方法

我熟悉Spring AOP.正如我在春季文档http://docs.spring.io/spring/docs/3.1.x/spring-framework-reference/html/aop.html中所读到的,Spring AOP致力于代理的概念.

在8.2.3.1支持的切入点指示符部分中,我找到了以下注释

Due to the proxy-based nature of Spring’s AOP framework,protected
methods are by definition not intercepted,neither for JDK proxies
(where this isn’t applicable) nor for CGLIB proxies (where this is
technically possible but not recommendable for AOP purposes). As a
consequence,any given pointcut will be matched against public methods
only!

起初,我不相信它,所以我试图在不使用接口的情况下实现它,默认情况下所有方法都是公开的,并且对上述情况感到惊讶.由于代理类是建议/目标对象的子类,受保护的方法可以由子类访问,所以我认为受保护的方法可以正常工作.

有人可以告诉我为什么不拦截受保护的方法?我错过了什么吗?

最佳答案
JDK代理基于接口,这意味着所有实现的方法都是公共的

相关文章

这篇文章主要介绍了spring的事务传播属性REQUIRED_NESTED的原...
今天小编给大家分享的是一文解析spring中事务的传播机制,相...
这篇文章主要介绍了SpringCloudAlibaba和SpringCloud有什么区...
本篇文章和大家了解一下SpringCloud整合XXL-Job的几个步骤。...
本篇文章和大家了解一下Spring延迟初始化会遇到什么问题。有...
这篇文章主要介绍了怎么使用Spring提供的不同缓存注解实现缓...