ClassPathXmlApplicationContext

张开发
2026/5/28 7:42:49 15 分钟阅读
ClassPathXmlApplicationContext
// 创建Spring上下文容器 ClassPathXmlApplicationContext context new ClassPathXmlApplicationContext(ApplicationContext.xml); // 从容器中获取bean假设我们有一个名为 helloWorld 的bean test helloWorld context.getBean(helloWorld, test.class); // 使用bean helloWorld.sayHello(); // 关闭上下文 context.close();重点

更多文章