December 31, 2011

Breaking a large applicationContext.xml configuration file into multiple files

0) Complete the Spring Framework Hello World example at this link

1) Create a new configuration file - applicationContext2.xml - in the WebContent/WEB-INF folder of the web application. Make sure that the root <beans> element is the same as in the applicationContext.xml

Move the <bean> configuration for the greetingService bean to the new configuration file and delete it from the applicationContext.xml

2) Modify the configuration in the web.xml by adding the new configuration file name, as follows,

<context-param>
     <param-name>contextConfigLocation</param-name>
     <param-value>/WEB-INF/applicationContext.xml /WEB-INF/applicationContext2.xml</param-value>
  </context-param>

3) Test the Hello World example as in the Hello World example

No comments:

Post a Comment