spring 第一个例子-mian函数-03
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());
}
}
本文来自博客园,作者:.net&new,转载请注明原文链接:https://www.cnblogs.com/wugh8726254/p/17378861.html