Reputation: 564
I am looking to create a Spring web application and I use Maven as the build automation tool. I prefer to go with multimodule application. The reason for modules are:
I have an admin module in my application and user module. The code changes in user module should not require testing of admin module.
Different development team work in user and admin modules
On POM module side I tend to go as follows
project/pom.xml #pom with <modules> element
project/parent/pom.xml #Parent pom
project/moduleX/pom.xml #module 'X'
project/moduleY/pom.xml #module 'Y'
Question is, when I go with modules approach are there any best practice I need to follow on Spring side?
Upvotes: 0
Views: 220
Reputation: 2747
applicationContex
You might want application context for each module:
...
<servlet>
<servlet-name>main-project</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/config/main-project-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>main-project</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/config/applicationContext-moduleX.xml
/WEB-INF/config/applicationContext-moduleY.xml
</param-value>
</context-param>
...
You need then a way to put in the same directory, /WEB-INF/config/
for example, the various application context by Maven Assembly Plugin or by overlaying with Maven War Plugin.
Upvotes: 1