在system-parent建立以下目錄web
├─system-daoapache
├─system-domain瀏覽器
├─system-serviceapp
└─system-webdom
mvn archetype:generate -DgroupId=com.hbb0b0 -DartifactId=system-parent -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -DarchetypeCatalog=localwebapp
<?xml version="1.0" encoding="UTF-8"?> <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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.hbb0b0</groupId> <artifactId>system-parent</artifactId> <packaging>pom</packaging> <version>1.0-SNAPSHOT</version> <name>system-parent</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <modules> <module>system-domain</module> <module>system-dao</module> <module>system-service</module> <module>system-web</module> </modules> </project>
mvn archetype:generate -DgroupId=com.hbb0b0 -DartifactId=system-domain -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -DarchetypeCatalog=localjsp
<?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.hbb0b0</groupId> <artifactId>system-parent</artifactId> <version>1.0-SNAPSHOT</version> </parent> <artifactId>system-domain</artifactId> <name>system-domain</name> <packaging>jar</packaging> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </project>
mvn archetype:generate -DgroupId=com.hbb0b0 -DartifactId=system-dao -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -DarchetypeCatalog=localmaven
<?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.hbb0b0</groupId> <artifactId>system-parent</artifactId> <version>1.0-SNAPSHOT</version> </parent> <artifactId>system-dao</artifactId> <packaging>jar</packaging> <name>system-dao</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>com.hbb0b0</groupId> <artifactId>system-domain</artifactId> <version>${project.version}</version> </dependency> </dependencies> </project>
mvn archetype:generate -DgroupId=com.hbb0b0 -DartifactId=system-service -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -DarchetypeCatalog=localui
<?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.hbb0b0</groupId> <artifactId>system-parent</artifactId> <version>1.0-SNAPSHOT</version> </parent> <artifactId>system-service</artifactId> <name>system-service</name> <packaging>jar</packaging> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>com.hbb0b0</groupId> <artifactId>system-dao</artifactId> <version>${project.version}</version> </dependency> </dependencies> </project>
mvn archetype:generate -DgroupId=com.hbb0b0 -DartifactId=system-web -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false -DarchetypeCatalog=localurl
<?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.hbb0b0</groupId> <artifactId>system-parent</artifactId> <version>1.0-SNAPSHOT</version> </parent> <artifactId>system-web</artifactId> <packaging>war</packaging> <name>system-web Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>com.hbb0b0</groupId> <artifactId>system-service</artifactId> <version>${project.version}</version> </dependency> </dependencies> <build> <finalName>system-web</finalName> <pluginManagement> <!--配置Jetty--> <plugins> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> </plugin> </plugins> </pluginManagement> </build> </project>
在 system-parent目錄運行
mvn clean install
執行成功以後 能夠看到如下輸出
[INFO] system-parent ...................................... SUCCESS [ 0.562 s]
[INFO] system-domain ...................................... SUCCESS [ 3.638 s]
[INFO] system-dao ......................................... SUCCESS [ 0.956 s]
[INFO] system-service ..................................... SUCCESS [ 0.956 s]
[INFO] system-web Maven Webapp ............................ SUCCESS [ 0.795 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.078 s
[INFO] Finished at: 2018-04-23T22:42:37+08:00
[INFO] Final Memory: 20M/192M
[INFO] ------------------------------------------------------------------------
mvn jetty:run
運行成功以後控制檯會輸出一下信息
[INFO] jetty-6.1.26
[INFO] No Transaction manager fo
[INFO] Started SelectChannelConn
[INFO] Started Jetty Server
maven web project
http://localhost:8080/system-web/
---system-dao
---system-domain
---system-service
---system-web