为什么Spring配置bean会变成另一个类名以$$EnhancerBySpringCGLIB结尾的bean

为什么Spring配置bean会变成另一个类名以$$EnhancerBySpringCGLIB结尾的bean,spring,spring-boot,Spring,Spring Boot,我在spring boot项目中定义了一个spring bean配置类,如下所示: @Configuration public class GgjSsoPropsConfig {} 但是在spring启动应用程序启动后,我尝试评估这个配置bean的类名,然后得到: // System.out.print(this.getClass().getSimpleName()) GgjSsoPropsConfig$$EnhancerBySpringCGLIB$$788ad0f1 我的bean似乎变成了

我在spring boot项目中定义了一个spring bean配置类,如下所示:

@Configuration
public class GgjSsoPropsConfig {}
但是在spring启动应用程序启动后,我尝试评估这个配置bean的类名,然后得到:

// System.out.print(this.getClass().getSimpleName())
GgjSsoPropsConfig$$EnhancerBySpringCGLIB$$788ad0f1
我的bean似乎变成了另一个“代理bean”?

顺便说一下,我从来没有在我的项目中启用任何
AOP
功能。

是的,它是。springaop使用CGLIB(与本例类似)或动态代理来创建bean实例并将其添加到应用程序上下文中


答案是肯定的,我在这个bean后期处理方法中找到了答案:
org.springframework.context.annotation.ConfigurationClassPostProcessor#enhanceConfigurationClasses

以下是该方法的官方评论:

Post处理BeanFactory以搜索配置类BeanDefinitions
然后通过{@link ConfigurationClassEnhancer}对所有候选项进行增强


事实上,这个新生成的增强器bean只是我的原始配置类
GgjSsoPropsConfig
的子类,它继承了父类的所有方法和字段,并在Spring中添加了一些额外的增强器特性

谢谢你的回答,但是我从来没有在我的项目中启用任何AOP特性,所以它不能是由AOP UTIL生成的代理对象