Bean 'com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration' of type [com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration$$EnhancerBySpringCGLIB$$49ec1f22] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 这个怎么解决
时间: 2024-03-06 14:50:29 浏览: 27
这个错误通常是由于 SentinelAutoConfiguration 类被 CGLIB 动态代理后,导致无法被所有的 BeanPostProcessors 处理。您可以尝试通过以下方法解决这个问题:
1. 尝试升级 Spring 版本,新版本的 Spring 可能已经修复了这个问题。
2. 在配置类上添加 @EnableAspectJAutoProxy(proxyTargetClass = true) 注解,启用 CGLIB 代理。
3. 禁用 SentinelAutoConfiguration 类的 CGLIB 代理,您可以在配置类中添加以下代码:
```
@Bean
public static BeanFactoryPostProcessor disableCglib() {
return (beanFactory) -> beanFactory.addBeanPostProcessor(new BeanPostProcessor() {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof SentinelAutoConfiguration) {
((DefaultListableBeanFactory) beanFactory).removeBeanDefinition(beanName);
}
return bean;
}
});
}
```
这个方法会创建一个 BeanFactoryPostProcessor,用于移除 SentinelAutoConfiguration 类的 Bean 定义,从而禁用 CGLIB 代理。
希望这些方法能够帮助您解决问题。
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)