You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
528 B

package com.ssm.di.xml;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestDI {
public static void main(String[] args) {
ApplicationContext ac = new ClassPathXmlApplicationContext("bean-di.xml");
// 终极写法:不指定类型,直接强转,彻底解决类型不匹配
Object obj = ac.getBean("lab");
System.out.println(obj);
((ClassPathXmlApplicationContext) ac).close();
}
}