标签:xml,03,spring,mian,ClassPathXmlApplicationContext,User From: https://www.cnblogs.com/wugh8726254/p/17378861.html
package com.sz.model;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class testMain {
public static void main(String[] args) {
//创建Spring上下文(加载bean.xml)
ApplicationContext acx = new ClassPathXmlApplicationContext("spring-config.xml");
//获取User实例
User user = acx.getBean("User", User.class);
//调用方法
System.out.println(user.toString());
}
}