@Configuration注解的属性proxyBeanMethods
先看源码
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
public @interface Configuration {
@AliasFor(annotation = Component.class)
String value() default "";
boolean proxyBeanMethods() default true;
}
这里新建两个类用来测试
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Human {
private String name;
private Pet pet;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Pet {
private String name;
}
然后新建一个配置类用来测试
@Configuration(proxyBeanMethods = true)
public class MyConfig {
@Bean
public Human human01() {
return new Human("kozo", tomcat());
}
@Bean
public Pet tomcat() {
return new Pet("tomcat");
}
}
在开关类的main方法中做验证
当proxyBeanMethods = true时
当proxyBeanMethods = false时,(这时idea给了一个提示)