Abstract: This article uses MAVEN to build a multi-module Web project
The project structure is as follows:
System-parent
|----Pom.xml
|----System-domain
|----Pom.xml
|----System-dao
|----Pom.xml
|----System-service
|----Pom.xml
|----System-web
|----Pom.xml
First, create the System-parent project
create a system-parent to inherit from each submodule
Tick Create a simple ...
Note To select Pom
Create a good structure as follows, remove the src file
Two
Creating a Sytem-domain module
Project Right Button-"New->other
Note Select Maven Module
packageing, select the jar, as this is to be packaged as a jar for other modules
The sub-modules are added as follows.
Open the System-domain project Pom.xml file and change it to the following
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > < Modelversion>4.0.0</modelversion><parent><groupid>com.mucfc</groupid><artifactid >system-parent</artifactid><version>0.0.1-snapshot</version></parent><artifactid >system-domain</artifactid><packaging>jar</packaging><name>system-domain</name ><url>http://maven.apache.org</url></project>
At this time system-parent should have such a sentence
<modules><module>system-domain</module></modules>
Indicates that the submodule was added successfully
Third, create System-dao module Steps and 2, named different
Then open the System-dao project under the Pom file, modified to read as follows:
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > < Modelversion>4.0.0</modelversion><parent><groupid>com.mucfc</groupid><artifactid >system-parent</artifactid><version>0.0.1-snapshot</version></parent><artifactid >system-dao</artifactId><packaging>jar</packaging><name>system-dao</name>< Url>http://maven.apache.org</url><dependencies> <!--System-dao need to use classes in System-domain, So you need to add a dependency on the System-domain module--><dependency><groupid>com.mucfc</groupid><artifactid> System-domain</artifactid> <version>${project.version}</version></dependency> </ Dependencies></project>
Iv. creating System-service module steps and 2, naming different
Then open the System-service project under the Pom file, modified to read as follows:
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > < Modelversion>4.0.0</modelversion><parent><groupid>com.mucfc</groupid><artifactid >system-parent</artifactid><version>0.0.1-snapshot</version></parent><artifactid >system-service</artifactid><packaging>jar</packaging><name>system-service</name ><url>http://maven.apache.org</url><dependencies><!-- System-service relies on System-dao and system-domain but we just need to add System-dao dependencies, because System-dao already relies on System-domain-->< dependency><groupid>com.mucfc</groupid><artifactid>system-dao</artifactid>< Version>${project.version}</version></dependency></dependencies></project>
V. Create a System-web module
The Web project is going to be packaged into a war file, so there's a place to change.
Remember to choose the War file here.
Change the pom file to read as follows:
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > < Modelversion>4.0.0</modelversion><parent><groupid>com.mucfc</groupid><artifactid >system-parent</artifactid><version>0.0.1-snapshot</version></parent><artifactid >system-web</artifactId><packaging>war</packaging><name>system-web</name>< url>http://maven.apache.org</url><dependencies><dependency><groupid>com.mucfc</ Groupid><artifactid>system-service</artifactid><version>${project.version}</version ></dependency></dependencies></project>
Then add a index.jsp in the \system-web\src\main\webapp directory yourself
Six, the overall directory is as follows
Vi. compiling and running the project
After the five steps above, the relevant modules are all created and how to run them. Since the final run is the System-web module, see here my other blog post maven TOMCAT7 automatic deployment
Copyright NOTICE: This article for Bo Master Lin Bingwen Evankaka original article, without Bo Master permission not reproduced.
MAVEN builds multi-module projects