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插件

原文地址:https://www.cnblogs.com/it-taosir/p/9728772.html