2

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 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!

1 Answer 1

7

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

Sign up to request clarification or add additional context in comments.

3 Comments

OK. I create a folder in src/main/webapp/WEB-INF/classes and put the client.xml in there and it seems to find it. Thanks.
the proper place is src/main/resources though.
OK. I put it in src/main/resources

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.