Config file in SpringFramework
Pack xml files in SpringFramework.
In my recent project, we are using a in-house framework (which i would be calling as “Framework”) which is backed by SpringFramework and Hiberante ( i had also added DWR support also ). We have actually added some helper methods and class hierarchies to avoid bolier plate code as much as possible.
One of the possible problems that i was thinkging was to have all of the SpringFramework related config files packed in a single jar file. As this will be in a jar file, so it would be difficult for the team who is using this framework (means that they wouldn’t really mess with the xml files) to go and possible modify them, which will eventually brick the framework.
I know that some of the readers will definately not agree, but to avoid potential problems, and to keep the Framework config files isolated from other .xml files that users will create for SpringMVC or other parts of Spring , we really needed to do that. Here is the solution :
First, you need to modify the web.xml and make it look like this :
[code lang=”xml”]
classpath*:adapter-config.xml,
classpath*:dao-tier-config.xml,
classpath*:service-config.xml,
classpath*:web-config.xml
[/code]
You will see that we added ‘classpath*:’ as prefix of every .xml file. We ingnored ‘myapp-servlet.xml’ as this file is not part of the framewok.
Next, add all of the files wiht ‘classpath*:’ in a single jar file and put it in the WEB-INF/lib folder. Thats all !.
This similar approach can also be used in the Spring based non-web applications.







