ClassPathXmlApplicationContext

张开发
2026/4/10 13:54:25 15 分钟阅读

分享文章

ClassPathXmlApplicationContext
// 创建Spring上下文容器 ClassPathXmlApplicationContext context new ClassPathXmlApplicationContext(ApplicationContext.xml); // 从容器中获取bean假设我们有一个名为 helloWorld 的bean test helloWorld context.getBean(helloWorld, test.class); // 使用bean helloWorld.sayHello(); // 关闭上下文 context.close();重点

更多文章