1. 程式人生 > >idea springcloud- maven 多模組化打包:

idea springcloud- maven 多模組化打包:

父類pom.xml 新增如下:

<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>
        
        <!--單元測試外掛-->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12.4</version>
            <configuration>
                <skipTests>true</skipTests>
            </configuration>
        </plugin>
    </plugins>
</build>

各個要打包的子專案pom.xml新增

<!--被打包專案必須配置項-->
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <!--配置為執行-->
        <classifier>exec</classifier>
    </configuration>
</plugin>
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>1.5.4.RELEASE</version>
    <configuration><!-- 指定該Main Class為全域性的唯一入口 -->
        <mainClass>ServerApplication</mainClass>
        <layout>ZIP</layout>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal><!--可以把依賴的包都打包到生成的Jar包中-->
            </goals>
        </execution>
    </executions>
</plugin>

配置好後開啟idea右側的maven projects執行下圖三項

看到

打包成功