摘要: 以前的bean是通过xml文件导入,若还想通过xml可以使用@Importresource @ImportResource("classpath:文件名.xml") //导入spring的配置文件 @ConfigurationProperties 配置绑定 eg:mysql账户密码等等 contro 阅读全文
posted @ 2021-06-27 18:13 YuyuFishSmile 阅读(56) 评论(0) 推荐(0)
摘要: 当满足某个条件的时候,才进行组件的注入 常见的如下: run.containsBean用于判断是否含有某个组件 System.out.println("++++++++++++++++++++++++++++++"); boolean tom = run.containsBean("tom"); S 阅读全文
posted @ 2021-06-27 17:29 YuyuFishSmile 阅读(103) 评论(0) 推荐(0)
摘要: @Component 代表一个组件 @Controller 代表是一个控制器 @Import({User.class}) //导入组件User类型的组件 @Import({User.class, DBAppender.class}) //导入组件User类型的组件,自动创建对应的无参构造器,创建出指 阅读全文
posted @ 2021-06-27 16:53 YuyuFishSmile 阅读(222) 评论(0) 推荐(0)
摘要: 一、 SSM中bean的创建 在springboot中可以不写xml文件,改为用@Configuration的方式,告诉Spring boot这是一个配置类 ~~~ 配置文件 //通过注解方式@Bean来给容器中添加组件,类似于在配置文件.xml中配置<bean id="" class=""><pr 阅读全文
posted @ 2021-06-27 16:38 YuyuFishSmile 阅读(278) 评论(0) 推荐(0)
摘要: 一、 在主程序中配置 @SpringBootApplication 相当于: //@SpringBootConfiguration @Configuration //主要由他组成 //@EnableAutoConfiguration @AutoConfigurationPackage @Import 阅读全文
posted @ 2021-06-27 15:07 YuyuFishSmile 阅读(143) 评论(0) 推荐(0)