繁体   English   中英

ClassPathXmlApplicationContext找不到xml文件

[英]ClassPathXmlApplicationContext cannot find the xml file

我阅读了几篇与此相关的文章,但仍然不明白如何解决我的问题。 我正在使用此源作为起点来创建Spring Web Servicehttp : //eggsylife.co.uk/2010/01/03/spring-3-restful-web-services/

它具有src/main/java文件夹和src/main/webapp/ ...

我想在com.spring.client/RestClient.java添加一个休息客户端:

public static void main(String[] args) {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("/META-INF/client-context.xml");
        RestTemplate restTemplate = (RestTemplate)ctx.getBean("restTemplate");

        addStudent(restTemplate);
    }

但是,当我尝试运行它时,无论放置在哪里,它都找不到client-context.xml文件。 我尝试了"client-context.xml""META-INF/client-context.xml"等。

我尝试将我的client-context.xml放在src/mainsrc/main/webappsrc/main/webapp/META-INFsrc/main/webapp/WEB-INF ,...

这看起来很奇怪。 我环顾四周,发现另一个工作正常的Spring REST教程。 在该项目中, src/main/webapp文件夹顶部有一个蓝色的“ S”,而我的其他项目也有。 这只是一个普通的文件夹。

这有什么区别吗? 我该如何解决这个错误?

谢谢!

src/main/resources/META-INF classpath的根是WEB-INF/classessrc/main/resourcessrc/main/java一起去

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM