溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

idea如何新建聚合項(xiàng)目

發(fā)布時(shí)間:2021-08-10 13:36:07 來源:億速云 閱讀:147 作者:小新 欄目:開發(fā)技術(shù)

這篇文章主要為大家展示了“idea如何新建聚合項(xiàng)目”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“idea如何新建聚合項(xiàng)目”這篇文章吧。

首先新建父工程

idea如何新建聚合項(xiàng)目

新建spring boot項(xiàng)目

idea如何新建聚合項(xiàng)目

填寫項(xiàng)目信息

idea如何新建聚合項(xiàng)目

指定該子項(xiàng)目的路徑

idea如何新建聚合項(xiàng)目

如果是組件類型的子項(xiàng)目 可以刪除application.xml和啟動(dòng)類

父工程pom文件

<?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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.demo</groupId>
    <artifactId>project</artifactId>
    <version>1.0.0-SNAPSHOT</version>
 
    <properties>
        <spring-boot.version>2.3.5.RELEASE</spring-boot.version>
    </properties>
 
    <modules>
        <module>common-mail</module>
    </modules>
 
    <packaging>pom</packaging>
 
    <dependencyManagement>
        <dependencies>   
            <dependency>
                <groupId>com.xx</groupId>
                <artifactId>common-assembly</artifactId>
                <version>${vanpeng.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
 
    <dependencies>
        <!-- swagger -->
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>1.5.10</version>
        </dependency>
    </dependencies>
 
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>
 
</project>

<modules>:為包含的子工程artifactId名
<properties>:指常量 一般為版本號(hào) 方便統(tǒng)一修改
<dependencyManagement>:指定子工程有相同jar包時(shí),使用父工程的版本號(hào),而子工程不用在額外指定
<dependencies>:為父子工程可以同時(shí)引入的jar包

子工程pom文件

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.demo</groupId>
        <artifactId>project</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>
 
    <groupId>com.demo</groupId>
    <artifactId>common-assembly</artifactId>
    <version>1.0.0-SNAPSHOT</version>
 
    <properties>
        <java.version>1.8</java.version>
        <spring-cloud.version>Hoxton.SR8</spring-cloud.version>
    </properties>
 
    <dependencies>
        <!-- 此處可以引入其他子工程包 -->
	    <dependency>
            <groupId>com.demo</groupId>
            <artifactId>common-resource</artifactId>
        </dependency>
    </dependencies>
 
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
 
    <build>
        <finalName>common-assembly-1.0.0-SNAPSHOT</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <includeSystemScope>true</includeSystemScope>
                    <mainClass>com.demo.assembly.BusinessApplication</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
 
</project>
 <parent>:為父工程的信息 也就是父工程pom中的groupId,artifactId 必填  <build>:為打包時(shí)的配置 

注意com.vanpeng.assembly.BusinessApplication一定要配置 否則jar包啟動(dòng)會(huì)找不到主函數(shù) pom也必須配置 這是在父子工程中必須配置的 意思是 需要以方式引入 而不是打成jar

以上是“idea如何新建聚合項(xiàng)目”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI