开发者

ClassPathXmlApplicationContext cannot find the xml file

I read several posts regarding this but still don't understand how to solve my issue. I am creating a Spring Web Service using this source as a starting point: http://eggsylife.co.uk/2010/01/03/spring-3-restful-web-services/

It has src/main/java folders and src/main/webapp/...

I want to add a rest client in com.spring.client/RestClient.java:

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

        addStudent(restTemplate);
    }

But when I try to run it, it cannot find the client-context.xml file no matter where I put it. I'tried "client-context.xml", "META-INF/client-context.xml", etc...

I've tried putting my client-context.xml in src/main, src/main/webapp, src/main/webapp/META-INF, src/main/webapp/WEB-INF, ...

It seems weird. I looked around and found another Spring REST tutorial with a working client. In that project, the src/main/webapp folders have a blue "S" on top of it while my other project does it. It's just a regular looking folder.

Does that make a difference? How do I fix this error?

Thanks!


src/main/resources/META-INF. The classpath root is WEB-INF/classes, and src/main/resources goes there, together with src/main/java

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜