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.

29 lines
1.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.ssm.di.xml;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestXML {
public static void main(String[] args) {
//1.初始化Spring容器加载配置文件
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("bean-di-xml.xml");
//获得Budget对象
Budget budget = (Budget) applicationContext.getBean("budget");
//输出Budget实例的信息
System.out.println(budget.toString());
// 获取Notice Bean
Notice notice = (Notice) applicationContext.getBean("notice");
System.out.println(notice.toString());
//获取Dict对象
Dict dict = (Dict) applicationContext.getBean("dict");
//输出Dict实例的信息
System.out.println(dict.toString());
//获得StockHolder对象
StockHolder stockHolder = (StockHolder) applicationContext.getBean("stockHolder");
//输出Budget实例的信息
System.out.println(stockHolder.toString());
}
}