项目结构图如下: 

   

在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. 修改应用进程open file值

    本文用于记录java应用日志too many open files报错解决方法 操作系统:RHEL5.8 一.修改配置文件 1.vim /etc/security/limits.conf 加上:* s ...

  2. sqlite 使用 cte 及 递归的实现示例

    1.多级 cte 查询示例. with cte as ( select pageid from cm_bookpage ) , cte2 as ( as content from cte ) sele ...

  3. IAR project build with command line

    The simple way is  that using iarbuild.exe project.eww -build Release/Debug Release/Debug is the con ...

  4. day02 python数据类型

    python里面常见的数据类型 目录 一.int 整形只有一个方法bit_length() 可以显示二进制长度 a = 10b = a.bit_length()print(b)1010 二.bool ...

  5. PHP数组和XML相互转换的函数

    //数组转xml function ArrToXml($arr) { if(!is_array($arr) || count($arr) == 0) return ''; $xml = "& ...

  6. sqlserver数据库不能重命名报错5030——我的一点小思考

    在学习asp.net的时候使用mssql‘经常会出现这种错误,数据库不能重名名5030的错误,其实很简单原因就是有应用程序正在占用这个连接,使用这样一行命令就可以查询出正在占用的连接 use mast ...

  7. 从零开始打jar包--补充

    想试一下动态编译的功能,所以想看一下java如何编译 原文见:http://www.cnblogs.com/flashsun/p/7246260.html 但这篇文章有些错误及遗漏之处,导致有些没有办 ...

  8. 解决腾讯云封锁SS(shadow--socks)访问google问题

    腾讯云windows主机,若使用SS(shadow--socks)采用加密算法aes-256-cfb,访问google的时候会被dropped connection. 解决办法更改ss server加 ...

  9. Java开发中判断集合类为空的方法-转载

    避免写两个判断 org.springframework.util.CollectionUtils 方法: public static boolean isEmpty(Collection collec ...

  10. 开发者必备的 12 个 JavaScript 库

    现在 web 设计是最有趣的了,做好 web 设计不仅要熟练使用 Javascript,css 和 html 等,还要有自己的创意设计.为了方便大家发挥自己的创意,就产生了很多 JS 框架,Node. ...