34 lines
1.2 KiB
Markdown
34 lines
1.2 KiB
Markdown
### 73.2. 使用Maven创建可执行JAR
|
||
|
||
`spring-boot-maven-plugin`能够用来创建可执行的'胖'JAR。如果你正在使用`spring-boot-starter-parent` POM,你可以简单地声明该插件,然后你的jar将被重新打包:
|
||
```xml
|
||
<build>
|
||
<plugins>
|
||
<plugin>
|
||
<groupId>org.springframework.boot</groupId>
|
||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||
</plugin>
|
||
</plugins>
|
||
</build>
|
||
```
|
||
如果没有使用parent POM,你仍旧可以使用该插件。不过,你需要另外添加一个`<executions>`片段:
|
||
```xml
|
||
<build>
|
||
<plugins>
|
||
<plugin>
|
||
<groupId>org.springframework.boot</groupId>
|
||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||
<version>1.3.0.BUILD-SNAPSHOT</version>
|
||
<executions>
|
||
<execution>
|
||
<goals>
|
||
<goal>repackage</goal>
|
||
</goals>
|
||
</execution>
|
||
</executions>
|
||
</plugin>
|
||
</plugins>
|
||
</build>
|
||
```
|
||
查看[插件文档](http://docs.spring.io/spring-boot/docs/1.3.0.BUILD-SNAPSHOT/maven-plugin/usage.html)获取详细的用例。
|