码迷,mamicode.com
首页 > 编程语言 > 详细

springboot项目不适用parent依赖,导致maven依赖无效

时间:2018-04-10 21:47:37      阅读:1562      评论:0      收藏:0      [点我收藏+]

标签:项目   repo   release   .com   必须   dem   ram   http   技术分享   

springboot项目的构建一般存在如下依赖:

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

 

如果删除这个依赖,会出现如下图问题:

技术分享图片

 

解决办法,引入maven依赖:

<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>

j经测试,打包的话,不能运行,不能使用java -jar demo.jar运行,会报错没有主清单。

必须添加如下插件

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.transferservice.TransferServiceApplication</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>

 

经测试,打包之后,使用命令java -jar demo.jar项目可以正常启动。







springboot项目不适用parent依赖,导致maven依赖无效

标签:项目   repo   release   .com   必须   dem   ram   http   技术分享   

原文地址:https://www.cnblogs.com/huangtao1927/p/8782692.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!