java.io.FileNotFoundException: class path resource cannot be opened because it does not exist

Rob_kael :

I am trying to set the configuration location for my Project but I keep getting the following error:

java.io.FileNotFoundException: class path resource [main/resources/app-context.xml] cannot be opened because it does not exist

I have my project set up like this:

enter image description here

And I have my code set up as:

ApplicationContext context = new ClassPathXmlApplicationContext(configLocation: "main/resources/app-context.xml");

How can I fix this?

JB Nizet :

What you put directly under src/main/java is in the default package, at the root of the classpath. It's the same for resources put under src/main/resources: they end up at the root of the classpath.

So the path of the resource is app-context.xml, not main/resources/app-context.xml.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=448718&siteId=1