1、spring_helloworld

使用maven的方式来构建项目(Mavaen)

  • 添加对应的pom依赖

    pom.xml
    <dependencies>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.2.3.RELEASE</version>
</dependency>
</dependencies>
  • 编写代码

    Person.java
  public class Person {
private int id;
private String name;
private int age;
private String gender; public int getId() {
return id;
} public void setId(int id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public int getAge() {
return age;
} public void setAge(int age) {
this.age = age;
} public String getGender() {
return gender;
} public void setGender(String gender) {
this.gender = gender;
} @Override
public String toString() {
return "Person{" +
"id=" + id +
", name='" + name + '\'' +
", age=" + age +
", gender='" + gender + '\'' +
'}';
}
}
  • 测试

    MyTest.java

 public class MyTest {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("ioc.xml");
Person person = (Person) context.getBean("person");
System.out.println(person);
}
}

总结:

  1. 一定要将配置文件添加到类路径中,使用idea创建项目的时候要放在resource目录下
  2. 创建对象给属性赋值的时候是通过setter方法实现
  3. 对象在IOC容器中存储的时候都是单例的,如果需要多例需要修改属性(默认单例,可以改多例)
  4. 对象在Spring容器创建完成的时候就已经创建完成,不是需要用的时候才创建(Application创建时候对象就创建了)
  5. ApplicationContext就是IOC容器的接口,可以通过此对象获取容器中创建的对象

2、spring对象的获取及属性赋值方式

1、通过bean的id获取IOC容器中的对象(上面已经用过)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!--
id 对象唯一标识
class 类名字:完全限定名字
-->
<bean id = "person" class="com.yao.bean.Person">
<property name="id" value="001"/>
<property name="name" value="yzh"/>
<property name="age" value="12"/>
<property name="gender" value="man"/>
</bean> </beans>

2、通过bean的类型获取对象

        ApplicationContext context = new ClassPathXmlApplicationContext("ioc.xml");
Person bean = context.getBean(Person.class);
System.out.println(bean);

注意:通过bean的类型在查找对象的时候,在配置文件中不能存在两个类型一致的bean对象,如果有的话,可以通过如下方法

    public class MyTest {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("ioc.xml");
Person person = context.getBean("person", Person.class);
System.out.println(person);
}
}

3、通过构造器给bean对象赋值

总结:

  • constructor-arg 给person类添加构造方法
  • 使用构造器赋值的时候可以省略name属性,但是此时就要求必须严格按照构造器参数的顺序来填写了
  • 如果想不按照顺序来添加参数值,那么可以搭配index属性来使用
  • 当有多个参数个数相同,不同类型的构造器的时候,可以通过type来强制类型
  • 两个重载的构造方法,后面的构造方法覆盖前面的构造方法。
constructor-arg中五个属性值:
value:赋值
name:成员属性
ref :通过ref引用其他对象,引用外部bean
index:如果想不按照顺序来添加参数值,那么可以搭配index属性来使用
type:当有多个参数个数相同,不同类型的构造器的时候,可以通过type来强制类型

ioc.xml

	<!--给person类添加构造方法-->
<bean id="person2" class="com.mashibing.bean.Person">
<constructor-arg name="id" value="1"></constructor-arg>
<constructor-arg name="name" value="lisi"></constructor-arg>
<constructor-arg name="age" value="20"></constructor-arg>
<constructor-arg name="gender" value="女"></constructor-arg>
</bean> <!--在使用构造器赋值的时候可以省略name属性,但是此时就要求必须严格按照构造器参数的顺序来填写了-->
<bean id="person3" class="com.mashibing.bean.Person">
<constructor-arg value="1"></constructor-arg>
<constructor-arg value="lisi"></constructor-arg>
<constructor-arg value="20"></constructor-arg>
<constructor-arg value="女"></constructor-arg>
</bean> <!--如果想不按照顺序来添加参数值,那么可以搭配index属性来使用-->
<bean id="person4" class="com.mashibing.bean.Person">
<constructor-arg value="lisi" index="1"></constructor-arg>
<constructor-arg value="1" index="0"></constructor-arg>
<constructor-arg value="女" index="3"></constructor-arg>
<constructor-arg value="20" index="2"></constructor-arg>
</bean>
<!--当有多个参数个数相同,不同类型的构造器的时候,可以通过type来强制类型-->
将person的age类型设置为Integer类型
public Person(int id, String name, Integer age) {
this.id = id;
this.name = name;
this.age = age;
System.out.println("Age");
}
// 后面的构造方法覆盖前面的构造方法。
public Person(int id, String name, String gender) {
this.id = id;
this.name = name;
this.gender = gender;
System.out.println("gender");
}
<bean id="person5" class="com.mashibing.bean.Person">
<constructor-arg value="1"></constructor-arg>
<constructor-arg value="lisi"></constructor-arg>
<constructor-arg value="20" type="java.lang.Integer"></constructor-arg>
</bean>
<!--如果不修改为integer类型,那么需要type跟index组合使用-->
<bean id="person5" class="com.mashibing.bean.Person">
<constructor-arg value="1"></constructor-arg>
<constructor-arg value="lisi"></constructor-arg>
<constructor-arg value="20" type="int" index="2"></constructor-arg>
</bean>

4、通过命名空间为bean赋值,简化配置文件中属性声明的写法

  • p导入命名空间,还有c命名空间,更简单的命名方式,仅此而已。、

    1、导入命名空间--xml一些规范带入就可以用啦
<?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:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

2、添加配置ioc.xml

  <bean id="person6" class="com.mashibing.bean.Person" p:id="3" p:name="wangwu" p:age="22" p:gender="男"></bean>

5、为复杂类型进行赋值操作(重点)

总结:

  • 给各种复杂类型赋值,如集合、数组、其他对象等。

    创建类如下:Person.java 、 Book.java、 Address.java 作为演示

Person.java

import java.util.*;

public class Person {
private int id;
private String name="dahuang";
private int age;
private String gender;
private Address address;
private String[] hobbies;
private List<Book> books;
private Set<Integer> sets;
private Map<String,Object> maps;
private Properties properties; // 没用过这个数据类型 public Person(int id, String name, int age, String gender) {
this.id = id;
this.name = name;
this.age = age;
this.gender = gender;
System.out.println("有参构造器");
} public Person(int id, String name, int age) {
this.id = id;
this.name = name;
this.age = age;
System.out.println("Age");
} public Person(int id, String name, String gender) {
this.id = id;
this.name = name;
this.gender = gender;
System.out.println("gender");
} public Person() {
} public int getId() {
return id;
} public void setId(int id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public int getAge() {
return age;
} public void setAge(int age) {
this.age = age;
} public String getGender() {
return gender;
} public void setGender(String gender) {
this.gender = gender;
} public Address getAddress() {
return address;
} public void setAddress(Address address) {
this.address = address;
} public List<Book> getBooks() {
return books;
} public void setBooks(List<Book> books) {
this.books = books;
} public Map<String, Object> getMaps() {
return maps;
} public void setMaps(Map<String, Object> maps) {
this.maps = maps;
} public Properties getProperties() {
return properties;
} public void setProperties(Properties properties) {
this.properties = properties;
} public String[] getHobbies() {
return hobbies;
} public void setHobbies(String[] hobbies) {
this.hobbies = hobbies;
} public Set<Integer> getSets() {
return sets;
} public void setSets(Set<Integer> sets) {
this.sets = sets;
} @Override
public String toString() {
return "Person{" +
"id=" + id +
", name='" + name + '\'' +
", age=" + age +
", gender='" + gender + '\'' +
", address=" + address +
", hobbies=" + Arrays.toString(hobbies) +
", books=" + books +
", sets=" + sets +
", maps=" + maps +
", properties=" + properties +
'}';
}
}

Book.java

public class Book {
private String name;
private String author;
private double price; public Book() {
} public Book(String name, String author, double price) {
this.name = name;
this.author = author;
this.price = price;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public String getAuthor() {
return author;
} public void setAuthor(String author) {
this.author = author;
} public double getPrice() {
return price;
} public void setPrice(double price) {
this.price = price;
} @Override
public String toString() {
return "Book{" +
"name='" + name + '\'' +
", author='" + author + '\'' +
", price=" + price +
'}';
}
}

Address.java

public class Address {
private String province;
private String city;
private String town; public Address() {
} public Address(String province, String city, String town) {
this.province = province;
this.city = city;
this.town = town;
} public String getProvince() {
return province;
} public void setProvince(String province) {
this.province = province;
} public String getCity() {
return city;
} public void setCity(String city) {
this.city = city;
} public String getTown() {
return town;
} public void setTown(String town) {
this.town = town;
} @Override
public String toString() {
return "Address{" +
"province='" + province + '\'' +
", city='" + city + '\'' +
", town='" + town + '\'' +
'}';
}
}

ioc.xml

给复杂类型的赋值都在property标签内进行

        1. 赋值为null
<property name="name">
<null></null>
</property>
2.外部引用 ref
3.引用内部bean
4.为list赋值
5.为set赋值
<property name="sets">
<set>
<value>111</value>
<value>222</value>
<value>222</value>
</set>
</property>
6。为map赋值
<property name="maps" ref="myMap"></property>
<util:map id="myMap">
<entry key="key1" value="value1"></entry>
<entry key="key2" value-ref="book2"></entry>
<entry key="key03">
<bean class="com.yao.bean.Book">
<property name="name" value="西游记" ></property>
<property name="author" value="吴承恩" ></property>
<property name="price" value="100" ></property>
</bean>
</entry>
</util:map>
7. 给数组赋值
<property name="hobbies">
<array>
<value>book</value>
<value>movie</value>
<value>game</value>
</array>
</property>

ioc.xml

  <?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:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd"
> <!--给复杂类型的赋值都在property标签内进行-->
<bean id="person" class="com.mashibing.bean.Person">
<property name="name">
<!--赋空值-->
<null></null>
</property>
<!--通过ref引用其他对象,引用外部bean-->
<property name="address" ref="address"></property>
<!--引用内部bean-->
<!-- <property name="address">
<bean class="com.mashibing.bean.Address">
<property name="province" value="北京"></property>
<property name="city" value="北京"></property>
<property name="town" value="西城区"></property>
</bean>
</property>-->
<!--为list赋值-->
<property name="books">
<list>
<!--内部bean-->
<bean id="book1" class="com.mashibing.bean.Book">
<property name="name" value="多线程与高并发"></property>
<property name="author" value="马士兵"></property>
<property name="price" value="1000"></property>
</bean>
<!--外部bean-->
<ref bean="book2"></ref>
</list>
</property>
<!--给map赋值-->
<property name="maps" ref="myMap"></property>
<!--给property赋值-->
<property name="properties">
<props>
<prop key="aaa">aaa</prop>
<prop key="bbb">222</prop>
</props>
</property>
<!--给数组赋值-->
<property name="hobbies">
<array>
<value>book</value>
<value>movie</value>
<value>game</value>
</array>
</property>
<!--给set赋值-->
<property name="sets">
<set>
<value>111</value>
<value>222</value>
<value>222</value>
</set>
</property>
</bean>
<bean id="address" class="com.mashibing.bean.Address">
<property name="province" value="河北"></property>
<property name="city" value="邯郸"></property>
<property name="town" value="武安"></property>
</bean>
<bean id="book2" class="com.mashibing.bean.Book">
<property name="name" value="JVM"></property>
<property name="author" value="马士兵"></property>
<property name="price" value="1200"></property>
</bean>
<!--级联属性-->
<bean id="person2" class="com.mashibing.bean.Person">
<property name="address" ref="address"></property>
<property name="address.province" value="北京"></property>
</bean>
<!--util名称空间创建集合类型的bean-->
<util:map id="myMap">
<entry key="key1" value="value1"></entry>
<entry key="key2" value-ref="book2"></entry>
<entry key="key03">
<bean class="com.mashibing.bean.Book">
<property name="name" value="西游记" ></property>
<property name="author" value="吴承恩" ></property>
<property name="price" value="100" ></property>
</bean>
</entry>
</util:map>
</beans>

6、继承关系bean的配置(暂时用不到)

意思就是bean可以继承

parent:指定bean的配置信息继承于哪个bean

parson2继承parson 修改了name

abstract: 抽象bean,值在里面,还是有就是不能实例化。abstract="true"

自己演示一下,好像没啥用奥。

ioc.xml

    <bean id="person" class="com.mashibing.bean.Person">
<property name="id" value="1"></property>
<property name="name" value="zhangsan"></property>
<property name="age" value="21"></property>
<property name="gender" value="男"></property>
</bean>
<!--parent:指定bean的配置信息继承于哪个bean-->
<bean id="person2" class="com.mashibing.bean.Person" parent="person">
<property name="name" value="lisi"></property>
</bean>

7、bean对象创建的依赖关系(暂时用不到)

bean对象在创建的时候是按照bean在配置文件的顺序决定的,也可以使用depend-on标签来决定顺序

    <bean id="book" class="com.mashibing.bean.Book" depends-on="person,address"></bean>
<bean id="address" class="com.mashibing.bean.Address"></bean>
<bean id="person" class="com.mashibing.bean.Person"></bean>

8、bean的作用域控制,是否是单例(一般两种)

细节点区别:(面试的时候细节点)

prototype:容器启动的时候不会创建多实例bean,只有在获取对象的时候才会创建该对象

singleton:在容器启动完成之前就已经创建好对象

  四种作用域
singleton 单例(默认的模式)
prototype 多例模式
spring 4.x版本中:
request: 每次发送请求都有一个新的对象
session:每次发送会话都有一个新的对象
这两种方式几乎不用。
测试singleton
Person2 person2 = context.getBean("person2",Person.class);
Person3 person3 = context.getBean("person3",Person.class);
System.out.println(Person2== person3); // ture;

ioc.xml

    <!--
bean的作用域:singleton、prototype、request、session
默认情况下是单例的
prototype:多实例的
容器启动的时候不会创建多实例bean,只有在获取对象的时候才会创建该对象
每次创建都是一个新的对象
singleton:默认的单例对象
在容器启动完成之前就已经创建好对象
获取的所有对象都是同一个
-->
<bean id="person4" class="com.mashibing.bean.Person" scope="prototype"></bean>

9、利用工厂模式创建bean对象

静态工厂and实例工厂区别?

静态工厂:工厂本身不需要创建对象,但是可以通过静态方法调用,对象=工厂类.静态工厂方法名();

实例工厂:工厂本身需要创建对象,工厂类 工厂对象=new 工厂类;工厂对象.get对象名();

优缺点:

实例工厂更容易扩展。

PersonStaticFactory.java

  public class PersonStaticFactory { // 静态工厂类

      public static Person getPerson(String name){
Person person = new Person();
person.setId(1);
person.setName(name);
return person;
}
}

ioc.xml

<!--
静态工厂的使用:
class:指定静态工厂类
factory-method:指定哪个方法是工厂方法
-->
<bean id="person5" class="com.mashibing.factory.PersonStaticFactory" factory-method="getPerson">
<!--constructor-arg:可以为方法指定参数-->
<constructor-arg value="lisi"></constructor-arg>
</bean>

Test.java

  工厂创建:用这个 不用PersonStaticFactory类,因为用的工厂方法创建的。
Person2 person2 = context.getBean("person2",Person.class);
System.out.println(Person2);

PersonInstanceFactory.java

  public class PersonInstanceFactory { // 实例工厂类 不加static!!
public Person getPerson(String name){
Person person = new Person();
person.setId(1);
person.setName(name);
return person;
}
}

ioc.xml

    <!--实例工厂使用-->
<!--创建实例工厂类-->
<bean id="personInstanceFactory" class="com.mashibing.factory.PersonInstanceFactory"></bean>
<!--
factory-bean:指定使用哪个工厂实例
factory-method:指定使用哪个工厂实例的方法
-->
<bean id="person6" class="com.mashibing.bean.Person" factory-bean="personInstanceFactory" factory-method="getPerson">
<constructor-arg value="wangwu"></constructor-arg>
</bean>

10、继承FactoryBean来创建对象(一般用不到,源码中看的多)

  BeanFactory 接口,规范
FactoryBean:获取唯一的对象。
自己创建的对象也可交给spring管理。
意思就是可以把我自己创建的交给Spring管理使用如下>
使用:
1)实现FactoryBean<那个类对象这里是person>接口
2)三个方法:
工厂方法,返回需要创建的对象
返回对象的类型
否是单例对象
3)交给spring 配置ioc.xml下面有
总结:
创建对象的补充,用的时候才创建不用不会创建。跟单例多例没有关系
自己不用。源码会用的多。

11、bean对象的初始化和销毁方法(了解)

初始化跟单例和多例有区别的:(一般没人使用,面试知道)
如果bean是单例,容器在启动的时候会创建好,关闭的时候会销毁创建的bean
如果bean是多例,获取的时候创建对象,销毁的时候不会有任何的调用

12、配置bean对象初始化方法的前后处理方法(了解)

POSTxxxx接口

3、spring创建第三方bean对象(配置数据库连接池)

1、导入数据库连接池的pom文件

  <!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.21</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>

2、编写配置文件

  <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!--
Spring管理第三方Bean对象
-->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
<property name="username" value="root"></property>
<property name="password" value="123456"></property>
<property name="url" value="jdbc:mysql://localhost:3306/demo"></property>
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
</bean>
</beans>

3、编写测试文件

  public class MyTest {
public static void main(String[] args) throws SQLException {
ApplicationContext context = new ClassPathXmlApplicationContext("ioc3.xml");
DruidDataSource dataSource = context.getBean("dataSource", DruidDataSource.class);
System.out.println(dataSource);
System.out.println(dataSource.getConnection());
}
}

4、spring引用外部配置文件

5、spring基于xml文件的自动装配

  前面有address这个类,在ioc.xml中,就是用的propotery装配。
现在自动装配:
怎么实现的?
byName:根据set方法后面首字幕大小写装配,必须首字幕小写。
Type:按照类型装配,有多个一样的类型就报错。

当一个对象中需要引用另外一个对象的时候,在之前的配置中我们都是通过property标签来进行手动配置的,其实在spring中还提供了一个非常强大的功能就是自动装配,可以按照我们指定的规则进行配置,配置的方式有以下几种:

default/no:不自动装配

byName:按照名字进行装配,以属性名作为id去容器中查找组件,进行赋值,如果找不到则装配null

byType:按照类型进行装配,以属性的类型作为查找依据去容器中找到这个组件,如果有多个类型相同的bean对象,那么会报异常,如果找不到则装配null

constructor:按照构造器进行装配,先按照有参构造器参数的类型进行装配,没有就直接装配null;如果按照类型找到了多个,那么就使用参数名作为id继续匹配,找到就装配,找不到就装配null

6、SpEL的使用(就是简单语法糖,写bean方便)

略:只有公司要求让你用的时候你再去看,现在看了不用也没啥用。

7、SpringIOC的注解应用

Spring中注解标识:

Spring中包含4个主要的组件添加注解:
@Controller:控制器,推荐给controller层添加此注解(接受用户请求 web用的到)
@Service:业务逻辑,推荐给业务逻辑层添加此注解
@Repository:仓库管理,推荐给数据访问层添加此注解
@Component:给不属于以上基层的**组件**添加此注解(啥也不懂就加这个)

注解使用步骤

使用注解需要如下步骤:
1、添加上述四个注解中的任意一个
2、添加自动扫描注解的组件,此操作需要依赖context命名空间
3、添加自动扫描的标签context:component-scan(当前包下面的所有类都进行扫描)

问题:在使用注解的时候咱们没有定义id和class他是怎么识别的呢?

默认类的名字首字母,小写,但是可以起别名,一般没人这么做,在注解标识括号中添加value = "xxxxxx",如@Controler(value = "类的名字就可以改");

扫描包可以做耕细粒度的划分(没啥用)

使用@AutoWired进行自动注入(理解困难,看看视频)

面试题:

  注意:当使用AutoWired注解的时候,自动装配的时候是根据类型实现的。
1、如果只找到一个,则直接进行赋值,
2、如果没有找到,则直接抛出异常,
3、如果找到多个,那么会按照变量名作为id继续匹配,
1、匹配上直接进行装配
2、如果匹配不上则直接报异常 还可以使用@Qualifier注解来指定id的名称,让spring不要使用变量名,当使用@Qualifier注解的时候也会有两种情况:
1、找到,则直接装配
​ 2、找不到,就会报错

@AutoWired可以进行定义在方法上

自动装配的注解@AutoWired,@Resource

面试题:

在使用自动装配的时候,出了可以使用@AutoWired注解之外,还可以使用@Resource注解,大家需要知道这**两个注解的区别**。
​ 1、@AutoWired:是spring中提供的注解,@Resource:是jdk中定义的注解,依靠的是java的标准
​ 2、@AutoWired默认是按照类型进行装配,默认情况下要求依赖的对象必须存在,@Resource默认是按照名字进行匹配的,同时可以指定name属性。
​ 3、@AutoWired只适合spring框架,而@Resource扩展性更好

6、泛型依赖注入(先跳过把)

Spring从入门到源码—IOC基本使用(二)的更多相关文章

  1. Spring从入门到源码(一)

    Spring 1.什么是框架? 人话就是:方便干活,架子有了,直接拿来用就完事了. spring,springmvc,mybatis三大开框架 2.架构的演变过程 单一应用架构 垂直应用架构 分布式服 ...

  2. Spring Boot入门,源码解析

    目录 1.Spring Boot简介 2.微服务 3.Spring Boot HelloWorld 3.1 创建一个Maven工程 3.2 导入依赖Spring Boot相关的依赖 3.3 编写一个主 ...

  3. Spring源码——IOC控制反转

    1.基础知识 Spring有两个核心功能,分别是ioc和aop,其中ioc是控制反转,aop是切面编程. 在ioc中,还有一个名次叫DI,也就是依赖注入.嗯,好像IOC和DI是指同一个,好像又感觉他俩 ...

  4. Spring源码-IOC部分-Spring是如何解决Bean循环依赖的【6】

    实验环境:spring-framework-5.0.2.jdk8.gradle4.3.1 Spring源码-IOC部分-容器简介[1] Spring源码-IOC部分-容器初始化过程[2] Spring ...

  5. Spring源码-IOC部分-容器简介【1】

    实验环境:spring-framework-5.0.2.jdk8.gradle4.3.1 Spring源码-IOC部分-容器简介[1] Spring源码-IOC部分-容器初始化过程[2] Spring ...

  6. Spring源码-IOC部分-容器初始化过程【2】

    实验环境:spring-framework-5.0.2.jdk8.gradle4.3.1 Spring源码-IOC部分-容器简介[1] Spring源码-IOC部分-容器初始化过程[2] Spring ...

  7. Spring源码-IOC部分-Xml Bean解析注册过程【3】

    实验环境:spring-framework-5.0.2.jdk8.gradle4.3.1 Spring源码-IOC部分-容器简介[1] Spring源码-IOC部分-容器初始化过程[2] Spring ...

  8. Spring源码-IOC部分-自定义IOC容器及Bean解析注册【4】

    实验环境:spring-framework-5.0.2.jdk8.gradle4.3.1 Spring源码-IOC部分-容器简介[1] Spring源码-IOC部分-容器初始化过程[2] Spring ...

  9. Spring源码-IOC部分-Bean实例化过程【5】

    实验环境:spring-framework-5.0.2.jdk8.gradle4.3.1 Spring源码-IOC部分-容器简介[1] Spring源码-IOC部分-容器初始化过程[2] Spring ...

随机推荐

  1. bash shell 中的 hash 命令有什么作用?

    linux 命令'hash'管理着一个内置的哈希表,记录了已执行过的命令的完整路径,用该命令可以打印出你所使用过的命令以及执行的次数. [root@localhost ~]# hashhits com ...

  2. Idea集成CSSO插件压缩css文件

    首先需要本地已安装node环境,并且csso-cli已通过npm安装到本地目录,只要能找到就行. 1. 打开Settings配置,确认图中的 File Watchers 插件是否已存在,如果不存在,去 ...

  3. eureka自我保护机制是什么?

    当Eureka Server 节点在短时间内丢失了过多实例的连接时(比如网络故障或频繁启动关闭客户端)节点会进入自我保护模式,保护注册信息,不再删除注册数据,故障恢复时,自动退出自我保护模式.

  4. 详细描述一下 Elasticsearch 索引文档的过程 ?

    面试官:想了解 ES 的底层原理,不再只关注业务层面了. 解答: 这里的索引文档应该理解为文档写入 ES,创建索引的过程. 文档写入包含:单文档写入和批量 bulk 写入,这里只解释一下:单文档写入流 ...

  5. 什么是 Ribbon负载均衡?

    (1)Spring Cloud Ribbon是基于Netflix Ribbon实现的一套客户端 负载均衡的工具. (2)Ribbon客户端组件提供一系列完善的配置项如连接超时,重试等.简单的说,就是在配 ...

  6. rabbitmq 中 vhost 的作用是什么?

    vhost本质上是一个mini版的RabbitMQ服务器,拥有自己的队列.绑定.交换器和权限控制: vhost通过在各个实例间提供逻辑上分离,允许你为不同应用程序安全保密地运行数据: vhost是AM ...

  7. spring-boot-learning-事务处理

     事务处理的重要性: 面对高井发场景, 掌握数据库事务机制是至关重要的,它能够帮助我们在一定程度上保证数据的一致性,并且有效提高系统性能,避免系统产生岩机,这对于互联网企业应用的成败是至关重要的. 以 ...

  8. 学习ELK日志平台(五)

    ELK Stack 通常情况下: 1,开发人员是不能登录线上服务器查看日志信息 2,各个系统的日志繁多,日志数据分散难以查找 3,日志数据量较大,查询速度慢,数据不够实时性 4,一个调用会涉及到多个系 ...

  9. 学习zabbix(三)

    前言: 学习zabbix之前,不得不了解的是SNMP协议 SNMP:简单网络管理协议(Simple Network Protocol) Snmp由两部分组成,监控端和被监控端 监控模式: 主动模式:N ...

  10. [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Name or service not known"

    修改/etc/resolv.conf文件 [root@lihui ~]# vi /etc/resolv.conf nameserver 8.8.8.8 nameserver 114.114.114.1 ...