项目结构图如下: 

   

在SpringBoot多模块项目打包时遇见如下错误:

1、repackage failed: Unable to find main class -> [Help 1]

解决步骤:

  (1)删除父pom中的build标签

  (2)在web模块的pom中配置,指定启动类,其他模块中不需要配置:

  <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.dh.yjt.SpringBootDemo.SpringBootDemoApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>

2、[ERROR] /xxx.java:[16,39] 程序包com.xx..xxx不存在

  解决办法:删除其他模块中的build标签

3、springboot打包与配置文件外置

  https://blog.csdn.net/pei19890521/article/details/80984707

  最终pom及package文件如下:

<?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">
<parent>
<artifactId>SpringBootDemo</artifactId>
<groupId>com.dh.yjt</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>mySystem-web</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>mySystem-web Maven Webapp</name>
<url>http://127.0.0.1/com.dh.yjt.SpringBootDemo.domain.index</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.dh.yjt</groupId>
<artifactId>mySystem-config</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.dh.yjt</groupId>
<artifactId>mySystem-dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.dh.yjt</groupId>
<artifactId>mySystem-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.dh.yjt</groupId>
<artifactId>mySystem-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.dh.yjt</groupId>
<artifactId>mySystem-domain</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency> <!-- xml配置 -->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<dependency>
<groupId>com.jd.jmq</groupId>
<artifactId>jmq-model</artifactId>
<version>2.1.4</version>
<scope>test</scope>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.dh.yjt.SpringBootDemo.SpringBootDemoApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/resources/package.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

package.xml:

<?xml version="1.0" encoding="UTF-8"?>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>package</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.basedir}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*.sql</include>
<include>*.bat</include>
<include>*.md</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/resources/bin</directory>
<outputDirectory>../</outputDirectory>
<includes>
<include>bin/*.sh</include>
<include>*.sh</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/resources</directory>
<outputDirectory>/conf</outputDirectory>
<includes>
<include>config/*.xml</include>
<include>config/*.properties</include>
<include>*.properties</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly>

SpringBoot多模块项目打包问题的更多相关文章

  1. 2017-09-26 发布 SpringBoot多模块项目实践(Multi-Module)

    https://segmentfault.com/a/1190000011367492?utm_source=tag-newest 2017-09-26 发布 SpringBoot多模块项目实践(Mu ...

  2. 使用IDEA构建Spring-boot多模块项目配置流程

    使用IDEA构建Spring-boot多模块项目配置流程 1.创建项目 点击Create New Project 在左侧选中Spring Initializer,保持默认配置,点击下一步. 在Grou ...

  3. 记Spring搭建功能完整的个人博客「Oyster」全过程[其二] Idea中Maven+SpringBoot多模块项目开发的设计和各种坑(模块间依赖和打包问题)

    大家好嘞,今天闲着没事干开写写博客,记录一下Maven+SpringBoot的多模块设计和遇到的坑. 多模块设计 简单说明一下截止目前的需求: 需要RESTful API:对文章.标签.分类和评论等的 ...

  4. 2 springboot多模块项目

    一般来说创建一个springboot工程基本就可以了,但是有的时候可能需要将业务模块逻辑划分,每块业务模块都是一个工程,下边演示下多模块进行开发 目录结构 ...somefun ......somef ...

  5. Maven多模块项目打包前的一些注意事项(打包失败)

    一. 最近在打包Maven项目时遇到了点问题,这个项目是Maven多模块项目,结构如下: projectParent├── xxxx-basic├── xxxx-web1├── xxxx-collec ...

  6. 使用Gradle构建springboot多模块项目,并混合groovy开发

    idea设置本地gradle 打包: build.gradle //声明gradle脚本自身需要使用的资源,优先执行 buildscript { ext { springBootVersion = ' ...

  7. docker部署 springboot 多模块项目+vue

    之前学习了docker,今天就来试试将这个项目打包成docker镜像并通过运行一个镜像来运行项目.这里使用的项目是el-admin.是一个开源的springboot后端管理框架(前端vue),有兴趣的 ...

  8. Java秒杀系统实战系列~构建SpringBoot多模块项目

    摘要:本篇博文是“Java秒杀系统实战系列文章”的第二篇,主要分享介绍如何采用IDEA,基于SpringBoot+SpringMVC+Mybatis+分布式中间件构建一个多模块的项目,即“秒杀系统”! ...

  9. springboot 多模块项目创建

    1.File>new>project  直接点击next 2.输入groupId  .artifactId 3.选择项目保存路劲  finish 4.成功创建多模块项目的根模块 5.创建子 ...

随机推荐

  1. 温度转换 II

    描述 温度的刻画有两个不同体系:摄氏度(Celsius)和华氏度(Fabrenheit). 请编写程序将用户输入华氏度转换为摄氏度,或将输入的摄氏度转换为华氏度. 转换算法如下:(C表示摄氏度.F表示 ...

  2. 计算机图形学----基于3D图形开发技术 (韩正贤 著)

    第1章 游戏模型 第2章 顶点处理机制 第3章 光栅化操作 第4章 片元处理和输出合并 第5章 光照和着色 第6章 参数曲线和表面 第7章 着色器模型 第8章 图像纹理 第9章 凹凸贴图 第10章 高 ...

  3. pyhanlp:hanlp的python接口

    HanLP的Python接口,支持自动下载与升级HanLP,兼容py2.py3. 安装 pip install pyhanlp 使用命令hanlp来验证安装,如因网络等原因自动安装失败,可参考手动配置 ...

  4. php7带来的性能升级

    前言本文是一篇讲座听后+后续研究的总结. 话说当年追时髦,php7一出就给电脑立马装上了,php5和php7共存,也是立马写了个超级耗时间的循环脚本测了一番,确实php7给力很多,然后也是注意了一些新 ...

  5. Presto 性能优化点

    1.指定需要返回的字段 [GOOD]: SELECT time,user,host FROM tbl[BAD]: SELECT * FROM tbl 2.合理设置分区字段 当过滤条件作用在分区字段上面 ...

  6. 双网卡单IP实现网卡冗余与负载均衡

    WINDOWS下: 所谓双网卡,就是通过软件将双网卡绑定为一个IP地址,这个技术对于许多朋友来说并不陌生,许多高档服务器网卡(例如intel8255x系列.3COM服务器网卡等)都具有多网卡绑定功能, ...

  7. python_hashlib模块

    1 网站登陆 import random import string import pickle # data1 = string.ascii_letters # print("data1数 ...

  8. c# 观察者模式 匿名方法与Lambda

    //匿名方法 //和委托搭配使用 //方便我们快速对委托进行传参 //不需要我们去定义一个新的函数 //直接用delegate关键字代替方法名,后面跟上参数列表与方法体 //delegate(参数列表 ...

  9. 【算法习题】正整数数组中和为sum的任意个数的组合数

    1.递归实现(参考:https://blog.csdn.net/hit_lk/article/details/53967627) public class Test { @org.junit.Test ...

  10. centos7 下安装zabbix3.0 agent

    设置YUM源:rpm -ivh http://mirrors.aliyun.com/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpmrpm - ...