项目结构图如下: 

   

在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. BigData_Jia

    #include <stdio.h> #include <string.h> #define MaxSize 10000 int n1, n2, i, k, times; ch ...

  2. sqlserver 知识点

    数据库知识点 1.数据库操作: 增:insert into 表名 values(值1,值2,值3) 删:delete 列名 from 表名 where 条件 改:update 表名 set =值 wh ...

  3. zabbix升级遇到连接不上数据库的问题

    问题 迁移zabbix-server端时,原来是4.0版本,现在为4.2版本,遇到如下问题       解决办法 update dbversion set mandatory=;        

  4. redis 缓存击穿 看一篇成高手系列3

    什么是缓存击穿 在谈论缓存击穿之前,我们先来回忆下从缓存中加载数据的逻辑,如下图所示 因此,如果黑客每次故意查询一个在缓存内必然不存在的数据,导致每次请求都要去存储层去查询,这样缓存就失去了意义.如果 ...

  5. excel安装wps后不能正常启动

    1. HKCU\Software\Microsoft\Office\15.0\Word\Options 设置NoReReg REG_DWORD =1 2.重命名C:\Program Files (x8 ...

  6. Spark环境准备

    Ubuntu: 1.下载spark-2.2.1-bin-hadoop2.7.tgz,解压即可使用. 2.下载jdk-8u151-linux-x64.tar.gz,解压. 3.执行spark-2.2.1 ...

  7. windows下安装hadoop

    环境 windows7 64位 JDK环境已经配置好(测试的是jdk1.8.0_191) hadoop体现结构: 下载Hadoop,地址 http://archive.apache.org/dist/ ...

  8. VirtualBox内Linux系统怎样与Windows共享文件夹

    Windows本机用虚拟机安装Linux系统(前提其他已配置好) 1. 双击无法安装,需要在扩展里添加:管理->全局设定->扩展 ->添加 或者 打开虚拟机进入Ubuntu系统,首先 ...

  9. awesome资源包

    .NET资源包 https://github.com/jobbole/awesome-dotnet-cn java资源包 https://github.com/jobbole/awesome-java ...

  10. 使用摄像头或视频运行 ORB-SLAM2 SLAM14讲 第一次课后作业

    参考:视觉SLAM十四讲(第一章作业) 深蓝上高博的第一讲课后题: 题目:6 * 使用摄像头或视频运行 ORB-SLAM2(3 分,约 1 小时)请注意本题为附加题.了解⼀样东西最快的⽅式是⾃⼰上⼿使 ...