我有一个 Spring 项目,我想在其中获取在我的 Spring beans XML 文件中定义的特定 Spring bean。我的 Spring bean XML 文件位于/WEB-INF/spring/root-context.xml
.
这是我在 Service 类中的代码:
ApplicationContext context = new ClassPathXmlApplicationContext("/WEB-INF/spring/root-context.xml");
这是我编译时遇到的错误:
parsing XML document from class path resource [WEB-INF/spring/root-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [WEB-INF/spring/root-context.xml] cannot be opened because it does not exist