1.怎麼理解maven的繼承和聚合
maven多模塊項目一般由一個父模塊和若干個子模塊構成,每一個模塊都對應着一個pom.xml。它們之間經過繼承和聚合(也稱做多模塊)相互關聯。多模塊適用於一些比較大的項目,經過合理的模塊拆分,實現代碼的複用,便於維護和管理。
繼承:和java中的繼承有點相似,就是父pom.xml聲明的版本和引用的jar,子模塊能夠不用再引用直接調用。
聚合:父模塊包含多個子模塊就是聚合,多個子模塊之間能夠調用,可是要注意關係,不要兩個互相依賴,這樣作的好處就是能夠經過一條命令進行構建java
注意:
groupId是項目組織惟一的標識符,實際對應JAVA的包的結構,artifactId是項目的惟一的標識符,實際對應項目的名稱,就是項目根目錄的名稱。groupId通常分爲多個段,通常第一段爲域,第二段爲公司名稱,第三段一般爲項目名稱。git
2.Idea建立多模塊項目github
pom.xml配置 <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.6.RELEASE</version> </parent> <groupId>cn.yskcoder.fire</groupId> <artifactId>fire</artifactId> <packaging>pom</packaging> <version>v1.0</version> <modules> <module>fire-common</module> <module>fire-dao</module> <module>fire-service</module> <module>fire-web</module> </modules> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <spring-boot.version>2.1.6.RELEASE</spring-boot.version> </properties>
pom.xml配置 <modelVersion>4.0.0</modelVersion> <parent> <artifactId>fire</artifactId> <groupId>cn.yskcoder.fire</groupId> <version>v1.0</version> </parent> <!--模塊信息--> <packaging>jar</packaging> <name>fire-common</name> <artifactId>fire-common</artifactId> <description>fire 通用工具類模塊</description> <!--模塊依賴--> <dependencies> </dependencies>
<modelVersion>4.0.0</modelVersion> <parent> <artifactId>fire</artifactId> <groupId>cn.yskcoder.fire</groupId> <version>v1.0</version> </parent> <!--模塊信息--> <packaging>war</packaging> <name>fire-web</name> <artifactId>fire-web</artifactId> <description>fire web模塊</description> <!--模塊依賴--> <dependencies> <dependency> <groupId>cn.yskcoder.fire</groupId> <artifactId>fire-service</artifactId> <version>v1.0</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>${java.version}</source> <target>${java.version}</target> </configuration> </plugin> </plugins> <resources> <resource> <directory>src/main/webapp</directory> <filtering>false</filtering> </resource> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> </build>
3.Idea打包多模塊項目clean package -Dmaven.test.skip=true
web
接下來有空會繼續更新這個項目
https://github.com/yskcoder/Firespring