摘要:
点击查看代码 ConfigurableApplicationContext context = SpringApplication.run(A45.class, args); Bean1 proxy = context.getBean(Bean1.class); /* 1.演示 spring 代理的 阅读全文
posted @ 2022-07-16 14:58
xy7112
阅读(23)
评论(0)
推荐(0)
摘要:
项目中,只需要加入以下依赖即可 在编译期扫描结束 <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-indexer</artifactId> <optional>true</optional> 阅读全文
posted @ 2022-07-16 14:46
xy7112
阅读(53)
评论(0)
推荐(0)
摘要:
点击查看代码 AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(A43.class); Bean1 bean1 = (Bean1) context.getBean("bean1"); 阅读全文
posted @ 2022-07-16 14:34
xy7112
阅读(19)
评论(0)
推荐(0)
摘要:
条件装配的底层是本质上是 @Conditional 与 Condition,这两个注解。引入自动配置类时,期望满足一定条件才能被 Spring 管理,不满足则不管理,怎么做呢? 比如条件是【类路径下必须有 dataSource】这个 bean ,怎么做呢? 首先编写条件判断类,它实现 Conditi 阅读全文
posted @ 2022-07-16 13:41
xy7112
阅读(28)
评论(0)
推荐(0)