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());
}
}
posted @ 2023-05-07 08:45  .net&new  阅读(14)  评论(0编辑  收藏  举报