bean的使用
无参构造:
有参构造:
红楼梦
水浒传
西游记
听歌
看书
学习
LOL
BOB
20211031
地址
root
123456
官方解释
使用!
测试!
注意:p命令和c命令不能直接使用,需要导入xml约束。并且p需要user类无参构造,c需要user类有参构造的支持
xmlns:p=“http://www.springframework.org/schema/p”
xmlns:c=“http://www.springframework.org/schema/c”
①:默认是单例,只创建一次:(scope=“singleton”)
②:原型模式,每次getBean都创建一个新的:
(scope=“prototype”)
-
自动装配式Spring满足bean依赖的一种方式!
-
Spring会在上下文中自动寻找,并自动给bean装配属性!
-
在Spring中有三种装配方式:
1.在xml中显示的配置
2.在Java中显示配置
3.隐式的自动装配bean【重要】
小结:
字段可以为空
@Autowired和@Qualifier可以配合使用
@Resourece
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=“http://www.springframework.org/schema/beans”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xmlns:context=“http://www.springframework.org/schema/context”
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
context:annotation-config/
<context:component-scan base-package=“com.xjc.*”/>
分享
这次面试我也做了一些总结,确实还有很多要学的东西。相关面试题也做了整理,可以分享给大家,了解一下面试真题,想进大厂的或者想跳槽的小伙伴不妨好好利用时间来学习。学习的脚步一定不能停止!
Spring Cloud实战
Spring Boot实战
面试题整理(性能优化+微服务+并发编程+开源框架+分布式)
base-package=“com.xjc.*”/>
分享
这次面试我也做了一些总结,确实还有很多要学的东西。相关面试题也做了整理,可以分享给大家,了解一下面试真题,想进大厂的或者想跳槽的小伙伴不妨好好利用时间来学习。学习的脚步一定不能停止!
[外链图片转存中…(img-WkMIavUf-1714159961374)]
Spring Cloud实战
[外链图片转存中…(img-yCCUNLUh-1714159961375)]
Spring Boot实战
[外链图片转存中…(img-Pna767o9-1714159961375)]
面试题整理(性能优化+微服务+并发编程+开源框架+分布式)