spring DI依赖注入
1、官网
https://docs.spring.io/spring/docs/5.2.7.RELEASE/spring-framework-reference/core.html#beans-dependencies
2、构造器注入(前面有)
3、Set方式注入(重点)
A、依赖 : bean对象 依赖 容器 创建
B、注入: bean对象的属性,由容器注入
https://docs.spring.io/spring/docs/5.2.7.RELEASE/spring-framework-reference/core.html#beans-factory-properties-detailed
案例
a、pojo
Address.java
package com.wt.pojo; public class Address { private String address; public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } @Override public String toString() { return "Address{" + "address=‘" + address + ‘‘‘ + ‘}‘; } }