zbb20190408 spring-boot-maven-plugin 插件的作用详解

本文介绍在Spring Boot项目中,如何配置spring-boot-maven-plugin插件以支持多个启动类,并详细说明了两种不同的配置方式:一种适用于继承自spring-boot-starter-parent的项目,另一种适用于未继承此父项目的配置。
添加了spring-boot-maven-plugin插件后,当运行maven打包的命令,项目会被打包成一个可以直接运行的jar包,使用"java -jar"可以直接运行。
当项目中有两个启动类时,需要制定要执行的类,如果不指定,启动会报错。
指定启动类有两种情况需要区分
一:pom文件继承自spring-boot-starter-parent
?
1
2
3
<properties>
  <start-class>com.xx.xx</start-class>
</properties>
二:pom文件不是继承自spring-boot-starter-parent
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-maven-plugin</artifactId>
     <version>2.0.5.RELEASE</version>
     <configuration>
      <mainClass>com.xx.xx</mainClass>
     </configuration>
     <executions>
      <execution>
      <goals>
        <goal>repackage</goal>
      </goals>
      </execution>
     </executions>
</plugin>
</plugins>
</build>
 

转载于:https://www.cnblogs.com/super-admin/p/10668624.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值