SpringBoot+Maven聚合多項目打包成jar


已我最近自己在玩的一個DEMO為例

taosir為pom.xml,其他子項目均為其modules,且為jar項目

eureka為注冊中心、workflow為提供者、entrance為調用方

entrance、workflow依賴於common

所以此處我需要將eureka、workflow、entrance三個打包成jar,那么它們的pom.xml文件中需加入

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

 

其他的子項目,包括父項目taosir的pom.xml都不要build

OK↓

 

在taosir項目右鍵  ->  run as  ->  maven build...

Run完即可在各項目的target文件夾下找到各自的jar包了!

cmd下 java -jar 文件路徑,即可運行

可能出現的問題及其解決

一、No compiler is provided in this environment. Perhaps you are running

 

on a JRE rather than a JDK

 

 

然后加上自己對應的jdk即可

 

二、invalid LOC header (bad signature)

去本地倉庫刪掉對應的不正確的jar包,重新update下項目

 

三、Exception occurred during processing request: Unable to compile class

for JSP

不再使用Maven 默認的 tomcat-maven-plugin 插件,改用tomcat(6、7、8等版本)-maven-plugin插件


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM