切面(@Aspect)和事务(@Transactional)莫名失效:`is not eligible for getting processed by all BeanPostProcesso

项目背景

​ 公司内部某架构系统,在shrio realm中注入使用了RedisUtils

    @Autowired
    RedisUtils redisUtils;

问题描述

本身项目的redis是使用aopyml控制开关的,但是突然发现aop失效了,无法开关redis在控制台没有报错出现但是有如下输出:

Bean 'shiroConfig' of type [com.jack.modules.njp.security.config.ShiroConfig$$EnhancerBySpringCGLIB$$7aac9763] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-02 15:33:31.267  INFO 7908 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.redis-org.springframework.boot.autoconfigure.data.redis.RedisProperties' of type [org.springframework.boot.autoconfigure.data.redis.RedisProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-02 15:33:31.270  INFO 7908 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration' of type [org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-02 15:33:31.348  INFO 7908 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'lettuceClientResources' of type [io.lettuce.core.resource.DefaultClientResources] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-02 15:33:31.401  INFO 7908 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'redisConnectionFactory' of type [org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-02 15:33:31.401  INFO 7908 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'redisConfig' of type [com.jack.common.redis.RedisConfig$$EnhancerBySpringCGLIB$$4dab53ba] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-02 15:33:31.509  INFO 7908 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'redisTemplate' of type [org.springframework.data.redis.core.RedisTemplate] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-02 15:33:31.510  INFO 7908 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'redisUtils' of type [com.jack.common.redis.RedisUtils] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-02 15:33:31.510  INFO 7908 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'oauth2Realm' of type [com.jack.modules.njp.security.oauth2.Oauth2Realm] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-02 15:33:31.516  INFO 7908 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'sessionManager' of type [org.apache.shiro.web.session.mgt.DefaultWebSessionManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-02 15:33:31.643  INFO 7908 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'securityManager' of type [org.apache.shiro.web.mgt.DefaultWebSecurityManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-02 15:33:31.688  INFO 7908 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'authorizationAttributeSourceAdvisor' of type [org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-02 15:33:31.871  INFO 7908 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.integration.config.IntegrationManagementConfiguration' of type [org.springframework.integration.config.IntegrationManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-02 15:33:31.886  INFO 7908 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'integrationChannelResolver' of type [org.springframework.integration.support.channel.BeanFactoryChannelResolver] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-02 15:33:31.888  INFO 7908 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'integrationDisposableAutoCreatedBeans' of type [org.springframework.integration.config.annotation.Disposables] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-02 15:33:32.143  INFO 7908 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : 

就突然发现有关于redisUtils的问题

redisUtils' of type [com.jack.common.redis.RedisUtils] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

翻译一下意思是 :该bean无法被所有的BeanPostProcessors处理(例如:无法创建自动代理)

无法aop本身就是基于代理实现的,现在无法获取代理类aop自然无法实现了。

问题解决

@Component
public class Oauth2Realm extends AuthorizingRealm {
    @Lazy
    @Autowired
    private ShiroService shiroService;

   @Lazy
    @Autowired
    RedisUtils redisUtils;
}

将realm 注入的autowired加上懒加载即可

原因分析

参考https://www.cnblogs.com/micrari/p/7354650.html bean的创建过程

org.springframework.beans.factory.support.AbstractBeanFactory#doGetBean打断点

很久才能进来

在这里插入图片描述

往前找依赖

redisUtils->oauth2Realm

在这里插入图片描述

redisUtils->oauth2Realm->securityManager

在这里插入图片描述

redisUtils->oauth2Realm->securityManager->shiroFilter

在这里插入图片描述

redisUtils->oauth2Realm->securityManager->shiroFilter->shiroConfig

在这里插入图片描述

在这里插入图片描述

在这里已经看到了shiroFilterpostprocessor

@Bean("shiroFilter")
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
    ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean();
    shiroFilter.setSecurityManager(securityManager);
}
public class ShiroFilterFactoryBean implements FactoryBean, BeanPostProcessor {

因为作为我们的redisUtils作为了postprocessor的依赖则无法创建代理

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值