前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >解决 SpringBoot 不继承父starter-parent打包不包含依赖的问题

解决 SpringBoot 不继承父starter-parent打包不包含依赖的问题

作者头像
stys35
发布2019-03-05 16:32:57
5.1K0
发布2019-03-05 16:32:57
举报
文章被收录于专栏:工作笔记精华工作笔记精华

由于项目需要继承自己平台的父 parent , 有的模块是纯 api ,不能有任何依赖, 所以父 parent 不能直接引入 springboot, 单独给非 boot 项目排除依赖的话又特别的麻烦, 且不好把控。

记得刚接触 SpringBoot 时看的官方文档里面有给方案。打开官网找了找。  官方文档:using-boot-maven-without-a-parent

官方让添加如下依赖管理

代码语言:javascript
复制
<dependencyManagement>
    <dependencies>
        <dependency>
            <!-- Import dependency management from Spring Boot -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>1.5.6.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

更换父 parent 加入依赖管理后, 可以正常运行, 但是打出的包是不包含依赖的。  也就是说, 我们不能直接使用 jar -jar demo.jar 的方式启动项目。

经过搜索, 找到了如下解决方案 原链接

代码语言:javascript
复制
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <mainClass>com.junbaor.test.App</mainClass>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
</plugin>

添加后再次打包, 一切正常。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018/12/11 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档