I have code like this in Main.java :
AbstractApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
Until recently it was working, but I don't know why it started failing with the below exception:
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring-config.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring-config.xml] cannot be opened because it does not exist
the spring-config.xml is in src/main/resources folder.
Actually I wanted to learn about the annotations: @Postconstruct and @Predestroy, so I changed the build path to Jdk 1.6 from Jdk 1.5.
Since then the problem started...
Any clue why it is not working?
NOTE: If any wants to see my project structure please follow this link http://code.google.com/p/javapracticeram/source/browse/trunk/SpringExample/
EDIT:
ClassPathResource is a Resource implementation for class path resources. It supports resolution as java. io. File if the class path resource resides in the file system, but not for resources in a JAR.
Introduction. When you build a java project and pack it into a jar (or a war), the files under the resources folder are included into the jar.
By default Spring Boot will serve static content from a directory called /static (or /public or /resources or /META-INF/resources) in the classpath.
Looking at your classpath you exclude src/main/resources
and src/test/resources
:
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
Is there a reason for it? Try not to exclude a classpath to spring-config.xml
:)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With