Is there a good way to load config file into ApplicationContext from WEB-INF directory using relative path?
I tried using ClassPathXmlApplicationContext and FileSystemXmlApplicationContext, but the first one works only for classpath resources and second one worked only with absolute path.
I already found 2 sollutions, but I don’t know if they are good.
- A added my WEB-INF folder to project classpath
- Move the config to resource folder (which is in classpath) and import it in WEB-INF by
<import resource="classpath:/batch/batch-config.xml" />
Please tell if one of these sollutions are good or what is the best sollution.
If you’re using FileSystemXmlApplicationContext, XMl configuration file should be specified with a full path or it should be at the path relative to the directory which application run.
if you’re using ClasspathXmlApplicationContext,Spring XML configuration file should be specified relative to the root of a classpath entry.
With my experience, I think your second approach is best way to define Spring Resources. More details