项目结构图如下: 

   

在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. Linux第五节课学习笔记

    Linux系统中的一切都是文件,命令就是命令文件. 命令执行分为4步: 1.路径+命令名称. 2.别名.可用alias命令创建别名. 3.内部命令. 4.外部命令.99%的情况都属于第四种.定义这些路 ...

  2. 汇编实验2(又是作业emm)

    实验任务:学会使用debug 1.使用Debug,将程序段写入内存: 首先对0021:0000~0021:000F的内存赋值 这里我赋的值是 11 12 13 14 15 16 17 18 输入mov ...

  3. TemplatePart特性的作用

    看wp控件的源代码时发现TemplatePart特性,于是在百度上查了查: http://blog.csdn.net/wushang923/article/details/9224533 Templa ...

  4. MySQL和MySQL的注释方式

    MySQL的注释方式   mysql 服务器支持如下几种注释方式: (1) # 到该行结束     # 这个注释直到该行结束 mysql> SELECT 1+1; (2)-- 到该行结束     ...

  5. Linux 命令备忘

    1.查看所有正在运行的进程:ps -A 2.运行一个可执行文件(切换到目标目录下,LinuxProject3为可执行文件名):./LinuxProject3

  6. 虚拟机安装精简版centos7过程

    虚拟机配置工作如下所示 1.创建虚拟机  使用键盘组合键CTRL+N2.选择自定义(高级) 如图所示: 3.默认如何所示: 4.选择 稍后安装操作系统 如图所示: 5.选择对应的操作系统 如何所示 6 ...

  7. Python Faker的使用(1):基础使用方法与函数速查,生成随机数据

    在软件需求.开发.测试过程中,有时候需要使用一些测试数据,针对这种情况,我们一般要么使用已有的系统数据,要么需要手动制造一些数据. 在手动制造数据的过程中,可能需要花费大量精力和工作量,现在好了,有一 ...

  8. 出现 OSError: symbolic link privilege not held的解决方案

    jupyter notebook  出现 OSError: symbolic link privilege not held问题时  以管理员方式重新打开prompt.

  9. 关于jeesite的陷阱需要注意

    jeesite,其框架主要为: 后端 核心框架:Spring Framework 4.0 安全框架:Apache Shiro 1.2 视图框架:Spring MVC 4.0 服务端验证:Hiberna ...

  10. win10自动更新后SQLServer无法启动的问题排查

    今天中午windows提示更新系统补丁并重启后发现,本地的SQL Server服务器没有正常启动,手工启动sqlserver也失败了,报错:找不到ERRORLOG文件及相应目录. 很是奇怪.强制创建该 ...