如果是普通的java程序,比如main拉起
public static void main(String[] args) {
ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("classpath*:META-INF/spring/application-context.bean.xml");
context.start();
这样就可以指定读取bean配置,放入上下文
如果是springboot,需要通过import注解引入
@SpringBootApplication
@ImportResource(locations={"classpath:META-INF/spring/service.bean.xml"})
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}