blob: 39532ceef990ba8c0715166fc32afc365354c691 [file] [log] [blame]
## Maven 构建 spring boot 可执行jar 相关配置
pluginManagement 模式)
### 配置
#### 主 pom,设置可用插件(如:samples/pom.xml)
```
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>boot-repackage</id>
<phase>package</phase>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
```
#### 项目 pom,配置(如:samples/user/pom.xml)
增加可执行jar 的启动类
```
<properties>
<start-class>com.supwisdom.leaveschool.user.UserApplication</start-class>
</properties>
```
设置打包文件名
```
<build>
<finalName>${project.artifactId}</finalName>
</build>
```
增加打包profile,用于打包时,须指定 -Pboot
```
<profiles>
<profile>
<id>boot</id>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
```
### 构建脚本
```
mvn clean package -Pboot
```