标签:strong new code 如何 pre ann not spi spring容器
1)SpringBoot框架获取容器中的对象
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
RestTemplate bean = (RestTemplate) context.getBean("restTemplate");
2)Spirng框架如何获取容器中的对象呢?
ApplicationContext context = new ClassPathXmlApplicationContext("application.xml")
RestTemplate bean = (RestTemplate) context.getBean("restTemplate");
标签:strong new code 如何 pre ann not spi spring容器
原文地址:https://www.cnblogs.com/pogusanqian/p/12956883.html