实例化容器
ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");
创建实例
OrderService orderService = ctx.getBean(OrderService.class);
其他
@Qualifier
类中同一类型对象定义了多个时,用Qualifier设置ID
@Primary
针对同一接口有多种实现且同时添加了@Component
、@Service
、@Repository
等注解,用Primary指定默认@Autowired