- user类:
转换结果:
-
- 注入参数还是上一篇所说的方法
-
支持最低版本spring4.1
- 运行方法要有所改变:
- 原来的:
-
//获取配置文件 ApplicationContext context = new ClassPathXmlApplicationContext("application.xml"); //配置文件自动扫描zhe.xin包下的component person person = context.getBean("person", person.class);
- 现在的:
-
@Test public void tests(){ //获取配置类 ApplicationContext context = new AnnotationConfigApplicationContext(JavaConfiguration.class); User getuser = context.getBean("getuser", User.class); System.out.println(getuser.toString()); }
2023-10-06/17:32:22
标签:xml,配置文件,spring,person,getuser,context,注解,class From: https://www.cnblogs.com/zhexin/p/17744769.html