摘要: @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface Import { /** * {@link Configuration}, {@link ImportSelecto 阅读全文
posted @ 2020-09-23 08:53 在谷歌上百度 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 采用注解的方式来注入bean 编写config类 /** * @author zhangjianbing * time 2020/09/23 * https://www.zhangjianbing.com */ @Configuration public class ConditionConfig 阅读全文
posted @ 2020-09-23 08:39 在谷歌上百度 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 懒加载,只有当使用Bean的时候才会被实例化。 @Configuration public class PersonConfig { /** * 懒加载主要用在单例模式上 * 标注了懒加载注解,容器初始化过程中不会实例化Bean * 只有当使用的时候才会实例化Bean,且只会实例化一次 */ @La 阅读全文
posted @ 2020-09-23 08:29 在谷歌上百度 阅读(164) 评论(0) 推荐(0) 编辑
摘要: Spring容器中的Bean默认是单例的,可以使用@Scope来设置Bean的类型 /** * @author zhangjianbing * time 2020/09/23 * https://www.zhangjianbing.com */ @Configuration public class 阅读全文
posted @ 2020-09-23 08:26 在谷歌上百度 阅读(151) 评论(0) 推荐(0) 编辑
摘要: @ComponentScan作用是将标注了@Controller、@Service、@Repository等注解的类放入IOC容器中,统一管理。 一、基本用法 Component组件: @Controller public class UserController { } @Service publ 阅读全文
posted @ 2020-09-23 08:22 在谷歌上百度 阅读(186) 评论(0) 推荐(0) 编辑