Spring Boot提供的Maven插件spring-boot-maven-plugin可以用来构建Fat Jar和可执行Jar。

1.Fat Jar

Fat Jar需要使用 java -jar xxx.jar 运行。要求在POM中使用:

1 <build>
2     <plugins>
3         <plugin>
4             <groupId>org.springframework.boot</groupId>
5             <artifactId>spring-boot-maven-plugin</artifactId>
6         </plugin>
7     </plugins>
8 </build>


此时构造出来的Fat Jar是没有可执行属性的。

2. 可执行Jar

相对于Fat Jar,可执行Jar多了可执行属性,可以通过  xxx.jar start  命令启动运行。

只要配置spring-boot-maven-plugin,启用可执行属性:

 1 <build>
 2     <plugins>
 3         <plugin>
 4             <groupId>org.springframework.boot</groupId>
 5             <artifactId>spring-boot-maven-plugin</artifactId>
 6             <configuration>
 7                 <executable>true</executable>
 8             </configuration>
 9         </plugin>
10     </plugins>
11 </build>


这样构建出来的是一个可执行Jar。

相关文章:

  • 2021-10-30
  • 2021-06-19
  • 2021-09-08
  • 2021-05-27
  • 2021-07-06
  • 2022-01-18
猜你喜欢
  • 2022-12-23
  • 2021-08-16
  • 2021-07-09
  • 2022-01-08
  • 2021-11-28
  • 2021-04-10
  • 2021-12-12
相关资源
相似解决方案