I'm trying to learn Spring3 by following book Pro Spring3. I'm in chapter 4 where the author explains IoC and DI. He uses GenericXmlApplicationContext to specify the configuration file. He does the following:
My question is how does it know exactly where app-context-annotation.xml is? I have this class in a package and my xml is in META-INF/spring/app-context-annotation.xml. How can I specify that the file is there? If I have it like the book says, I get:
IOException parsing XML document from class path resource [app-context-annotation.xml]; nested exception is java.io.FileNotFoundException: class path resource [app-context-annotation.xml] cannot be opened because it does not exist
Basically, in the book there is that "classpath:" in the front of the file name. That tells Spring to look in the classpath for the file. But without any pathing after classpath: means that it will look for that file only in the root of the classpath. So you have to tell Spring from the root of the classpath, what is the path to the file.
In your case you are using Maven, so anything in the src/main/resources/ directory will be copied to the root of the classpath.
src/main/resources/mark.txt copied to the root of the classpath
src/main/resources/something/anotherDir/myfile.txt is copied to
/something/anotherDir/myfile.txt off the root of the classpath.