4、第二种注入方式:使用有参数构造进行注入
(1)创建类,定义属性,创建属性对应有参数构造方法
public class Orders {
private String oname;
private String adress;
public Orders(String oname, String adress) {
this.oname = oname;
this.adress = adress;
}
public void test(){
System.out.println("test......");
}
@Override
public String toString() {
return "Orders{" +
"oname='" + oname + '\'' +
", adress='" + adress + '\'' +
'}';
}
}
(2)在spring配置文件中进行配置
<?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:s