- 創(chuàng)建父項(xiàng)目common-parent
- File>>New>>Project>>Empty Project>>填寫(xiě)項(xiàng)目名稱和項(xiàng)目路徑>>Finish
- File>>New>>Module>>選擇maven>>Create from archetype>>maven-archetype-quickstart>>Next>>GroupId>>ArtifactId>>Next>>Maven home dictory>>User setting file>>Override>>Next>>Module name[common-parent]>>Content root>>Next>>等待生成pom文件
- 修改pom.xml文件
<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> <groupId>co.mico</groupId> <artifactId>common-parent</artifactId> <version>1.0-SNAPSHOT</version> <packaging>pom</packaging><!--修改打包方式--> <name>common-parent</name> <url>http://maven.apache.org</url> <!--集中定義依賴版本號(hào)--> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <junit.version>4.12</junit.version> ...(省略) </properties> <dependencyManagement> <dependencies> <!-- 時(shí)間操作組件 --> <dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> <version>${joda-time.version}</version> </dependency> ...(省略) </dependencyManagement> <build> <finalName>${project.artifactId}</finalName> <plugins> <!-- 資源文件拷貝插件 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.7</version> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> <!-- java編譯插件 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build> </project> - 創(chuàng)建子項(xiàng)目公共工具類common-utils
- 公共工具類是繼承自父項(xiàng)目common-parent
- File>>New>>Module>>選擇maven>>Create from archetype>>maven-archetype-portlet>>Add as module to [這里選擇none]>>Parent[這里是cn.william.common-parent] >>GroupId>>ArtifactId>>Next>>Maven home dictory>>User setting file>>Override>>Next>>Module name[common-utils]>>Content Root[注意修改目錄結(jié)構(gòu),common-parent同級(jí)目錄](méi)>>Next>>等待生成pom文件
- 修改pom文件,打包方式為jar
<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"> <parent> <artifactId>common-parent</artifactId> <groupId>cn.william</groupId> <version>1.0-SNAPSHOT</version> <relativePath>../common-parent/pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>common-utils</artifactId> <packaging>jar</packaging><!-- 打成jar包 --> <name>common-utils</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <!-- jar包的依賴 --> <dependencies> <!-- 時(shí)間操作組件 --> <dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> </dependency> ...(省略) </dependencies> </project> - 創(chuàng)建子項(xiàng)目taotao-manager[開(kāi)發(fā)項(xiàng)目],與工具類的創(chuàng)建方式一致,打包方式為pom
<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"> <parent> <artifactId>common-parent</artifactId> <groupId>cn.william</groupId> <version>1.0-SNAPSHOT</version> <relativePath>../common-parent/pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>uncertain-manager</artifactId> <packaging>pom</packaging> <name>uncertain-manager</name> <url>http://maven.apache.org</url> <modules> <module>taotao-manager-pojo</module> <module>taotao-manager-mapper</module> <module>taotao-manager-service</module> <module>taotao-manager-web</module> </modules> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <!-- 依賴管理 --> <dependencies> <dependency> <groupId>cn.william</groupId> <artifactId>common-utils</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> <build> <!-- 配置插件 --> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <configuration> <port>8080</port> <path>/</path> </configuration> </plugin> </plugins> </build> </project> - 創(chuàng)建開(kāi)發(fā)項(xiàng)目的子項(xiàng)目taotao-manager-pojo
- 選中ncertain-manager項(xiàng)目>>New>>>>選擇maven>>Create from archetype>>maven-archetype-quickstart>>Add as module to [這里選擇cn.william.uncertain-manager]>>Parent[這里是cn.william.uncertain-manager] >>GroupId>>ArtifactId>>Next>>Maven home dictory>>User setting file>>Override>>Next>>Module name[uncertain-manager-pojo]>>Content Root[注意修改目錄結(jié)構(gòu),uncertain-manager下級(jí)目錄](méi)>>Next>>等待生成pom文件
- 修改pom文件
<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"> <parent> <artifactId>taotao-manager</artifactId> <groupId>cn.william</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>taotao-manager-pojo</artifactId> <packaging>jar</packaging> <name>taotao-manager-pojo</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> </project>
- 創(chuàng)建開(kāi)發(fā)項(xiàng)目的子項(xiàng)目taotao-manager-mapper,創(chuàng)建方式與pojo項(xiàng)目一致,打包方式也為jar,但是mapper項(xiàng)目依賴pojo項(xiàng)目:
- pom文件依賴配置
<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"> <parent> <artifactId>taotao-manager</artifactId> <groupId>cn.william</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>taotao-manager-mapper</artifactId> <packaging>jar</packaging> <name>taotao-manager-mapper</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <!-- 依賴與pojo子模塊 --> <dependency> <groupId>cn.william</groupId> <artifactId>taotao-manager-pojo</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <!-- Mybatis --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> </dependency> <dependency> <groupId>com.github.miemiedev</groupId> <artifactId>mybatis-paginator</artifactId> </dependency> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> </dependency> <!-- MySql --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!-- 連接池 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> </dependency> </dependencies> </project>
- pom文件依賴配置
- 創(chuàng)建開(kāi)發(fā)項(xiàng)目的子項(xiàng)目taotao-manager-service,創(chuàng)建方式與pojo項(xiàng)目一致,打包方式也為jar,但是service項(xiàng)目依賴mapper項(xiàng)目:
- pom文件
<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"> <parent> <artifactId>taotao-manager</artifactId> <groupId>cn.william</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>taotao-manager-service</artifactId> <packaging>jar</packaging> <name>taotao-manager-service</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <!-- 依賴與mapper子模塊 --> <dependency> <groupId>cn.william</groupId> <artifactId>taotao-manager-mapper</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <!-- Spring --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> </dependency> ...(省略) </dependencies> </project> - 創(chuàng)建開(kāi)發(fā)項(xiàng)目的子項(xiàng)目taotao-manager-web,創(chuàng)建方式與pojo項(xiàng)目一致,打包方式為war,archetype是maven-archetype-quickstart,web項(xiàng)目依賴service項(xiàng)目
- pom文件配置
<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"> <parent> <artifactId>taotao-manager</artifactId> <groupId>cn.william</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>taotao-manager-web</artifactId> <packaging>war</packaging><!--打成war包--> <name>taotao-manager-web Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <!-- 依賴于service --> <dependency> <groupId>cn.william</groupId> <artifactId>taotao-manager-service</artifactId> <version>1.0-SNAPSHOT</version> </dependency> ...(省略) </dependencies> <build> <finalName>taotao-manager-web</finalName> </build> </project> - 運(yùn)行
- web項(xiàng)目下新建index.jsp
- 確保taotao-manager的pom中配置了tomcat的插件
<build> <!-- 配置插件 --> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <configuration> <port>8080</port> <path>/</path> </configuration> </plugin> </plugins> </build>- Run>>Edit Configurations>>Add New Configurations>>Maven>>Name[taotao-manager]>>Working directory[taotao-manger項(xiàng)目的目錄](méi)>>Command line[clean tomcat7:run]
- Run之前先將所有模塊安裝一下
- 圖文原文:基于maven使用IDEA創(chuàng)建多模塊項(xiàng)目
IDEA maven3 構(gòu)建多模塊項(xiàng)目
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 簡(jiǎn)書(shū) Wwwwei轉(zhuǎn)載請(qǐng)注明原創(chuàng)出處,謝謝! 一些概念 Maven 一個(gè)項(xiàng)目管理工具,簡(jiǎn)單的理解為一種標(biāo)準(zhǔn)化的方式...
- Spring Cloud為開(kāi)發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見(jiàn)模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
- Spring Boot 參考指南 介紹 轉(zhuǎn)載自:https://www.gitbook.com/book/qbgb...
- 我jdk版本是1.7.0_95,在網(wǎng)上查了一下1.7屬于java7maven3.3+版本都支持java7,所以我使...
- 1、高山茶葉,低山茶子。 2、吃茶吃味道,看戲看成套。 3、茶為萬(wàn)病之藥。 4、茶是草,客是寶,得罪茶商不得了。 ...