SpringBoot多模块项目打包问题
项目结构图如下:
在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多模块项目打包问题的更多相关文章
- 2017-09-26 发布 SpringBoot多模块项目实践(Multi-Module)
https://segmentfault.com/a/1190000011367492?utm_source=tag-newest 2017-09-26 发布 SpringBoot多模块项目实践(Mu ...
- 使用IDEA构建Spring-boot多模块项目配置流程
使用IDEA构建Spring-boot多模块项目配置流程 1.创建项目 点击Create New Project 在左侧选中Spring Initializer,保持默认配置,点击下一步. 在Grou ...
- 记Spring搭建功能完整的个人博客「Oyster」全过程[其二] Idea中Maven+SpringBoot多模块项目开发的设计和各种坑(模块间依赖和打包问题)
大家好嘞,今天闲着没事干开写写博客,记录一下Maven+SpringBoot的多模块设计和遇到的坑. 多模块设计 简单说明一下截止目前的需求: 需要RESTful API:对文章.标签.分类和评论等的 ...
- 2 springboot多模块项目
一般来说创建一个springboot工程基本就可以了,但是有的时候可能需要将业务模块逻辑划分,每块业务模块都是一个工程,下边演示下多模块进行开发 目录结构 ...somefun ......somef ...
- Maven多模块项目打包前的一些注意事项(打包失败)
一. 最近在打包Maven项目时遇到了点问题,这个项目是Maven多模块项目,结构如下: projectParent├── xxxx-basic├── xxxx-web1├── xxxx-collec ...
- 使用Gradle构建springboot多模块项目,并混合groovy开发
idea设置本地gradle 打包: build.gradle //声明gradle脚本自身需要使用的资源,优先执行 buildscript { ext { springBootVersion = ' ...
- docker部署 springboot 多模块项目+vue
之前学习了docker,今天就来试试将这个项目打包成docker镜像并通过运行一个镜像来运行项目.这里使用的项目是el-admin.是一个开源的springboot后端管理框架(前端vue),有兴趣的 ...
- Java秒杀系统实战系列~构建SpringBoot多模块项目
摘要:本篇博文是“Java秒杀系统实战系列文章”的第二篇,主要分享介绍如何采用IDEA,基于SpringBoot+SpringMVC+Mybatis+分布式中间件构建一个多模块的项目,即“秒杀系统”! ...
- springboot 多模块项目创建
1.File>new>project 直接点击next 2.输入groupId .artifactId 3.选择项目保存路劲 finish 4.成功创建多模块项目的根模块 5.创建子 ...
随机推荐
- Merging one UE4 project into another.
Merging can be done by right clicking on folder in the content directory in the editor and selecting ...
- 像使用数据库一样使用xml
目录 xml简介 语言结构 tinyxml 下载tinyxml 应用实例 tinyxml的封装 封装源码 实际应用 xml简介 XML 没什么特别的.它仅仅是纯文本而已.有能力处理纯文本的软件都可以处 ...
- POJ3208 Apocalypse Someday
题意 Language:Default Apocalypse Someday Time Limit: 1000MS Memory Limit: 131072K Total Submissions: 2 ...
- SQL Server Service Broker 示例(转)
1.定义数据类型.协议和服务(发送服务和接收服务) USE master; GO ALTER DATABASE 目标数据库 SET ENABLE_BROKER; GO -- 如果上面的操作执行后,长时 ...
- flagr 数据库配置
flagr 是一个很不错的特性开关.a/b 测试服务,默认使用的是sqlite 数据库,但是我们可以通过配置,使用不同的数据库 sqlite.mysql.postrgresql.json_file.j ...
- python 常用库
Numpy, Pandas 数据处理 Scipy 科学计算 Matplotlib 可视化 Scikit Learn 机器学习 Keras 深度学习模型 jieba 分词 Gensim 主题(包含 ...
- C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(388,5): warning MSB8028: The intermediate directory (Debug) contains files shared from another project (GU.vcxproj). T
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(388,5): warni ...
- PCI9054 总结(讲解非常清楚)
转载自:http://blog.csdn.net/lg2lh/article/details/8042008 PCI的基本协议这里就不介绍了,因为一般的芯片协议都是集成好的,我只需要大体了解就行,不需 ...
- PySide2兼容PySide1的补丁代码
Maya2017以及Nuke10的PySide都升级到PySide2了,之前PySide1的大量代码都无法在新软件上使用,这主要是由于PySide2不仅调整了模块位置,还增删了一系列模块,下面我分享一 ...
- MAC基本操作
1:软件的安装,卸载和破解 (1)mac上的软件包的安装可以去appstore或者是去第三方网站下载,下载下来的安装包一般是dmp,pkg,iso文件.最终安装之后生成的文件是app文件就可以使用.通 ...