//首先创建一个 Student 类
@Test
public void testStudent(){
Student student = new Student();
System.out.println(student);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
factory.registerSingleton("student",student);
Student student1 = factory.getBean("student", Student.class);
System.out.println(student1);
}
输出结果:
com.powernode.spring6.bean.Student@7907ec20
com.powernode.spring6.bean.Student@7907ec20