Spring之IOC通过构造方法实例化Bean的方式
程序员文章站
2022-05-23 15:19:29
...
Spring框架搭建实例
Spring之IOC创建对象的方式
我们的学生类Student代码
package com.lingaolu; /** * @author 林高禄 * @create 2020-11-03-9:19 */ public class Student { private Long id; private String name; private String no; public Student() { System.out.println("Student无参构造执行"); } public Student(String name, String no) { System.out.println("Student半参构造执行"); this.name = name; this.no = no; } public Student(Long id, String name, String no) { System.out.println("Student全参构造执行"); this.id = id; this.name = name; this.no = no; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getNo() { return no; } public void setNo(String no) { this.no = no; } @Override public String toString() { return "Student{" + "id=" + id + ", name='" + name + '\'' + ", no='" + no + '\'' + '}'; } }
无参构造方法
有参构造方法
constructor-arg index
constructor-arg index
综合
上一篇: php数组冒泡排序算法实例代码
下一篇: 界面显示出现乱码,该怎么解决