parent
e131932082
commit
36b26d2da9
@ -0,0 +1,24 @@
|
||||
package com.ssm.ioc;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
public class TestDi {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 1. 读取 bean-di.xml 配置文件
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("bean-di.xml");
|
||||
|
||||
// 2. 获取实验室对象并打印
|
||||
System.out.println("=== 实验室信息 ===");
|
||||
Lab lab = (Lab) context.getBean("lab");
|
||||
System.out.println(lab);
|
||||
|
||||
// 3. 获取材料对象并打印
|
||||
System.out.println("\n=== 材料信息 ===");
|
||||
Materialz material = (Materialz) context.getBean("materialz");
|
||||
System.out.println(material);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in new issue