当前位置:   article > 正文

SpringBoot 打可执行生产包_spring boot打包完jar怎么确定jar包打的是生产的

spring boot打包完jar怎么确定jar包打的是生产的

       SpringBoot 自带模块可单独打包成可运行的jar,对于拥有整套微服务框架的企业来说是非常友好的,只需要一个配置中心,完美解决不同环境不同配置的问题,但对于只使用SpringBoot的企业来说,需要配置跟着环境走,所以百度各方资料,整理出相关配置项,让你的SpringBoot 应用可以各目录分离


执行打包命令:

mvn clean package

在当前target目录下生成程序包:

cn-rongplus-msg-receive.tar.gz 

解压后查看目录结构:

  1. ls -al
  2. total 8
  3. drwxr-xr-x 8 liugang staff 256 Aug 22 16:17 .
  4. drwxr-xr-x 13 liugang staff 416 Aug 22 16:17 ..
  5. -rwxr-xr-x 1 liugang staff 646 Jul 29 13:40 README.md
  6. drwxr-xr-x 4 liugang staff 128 Aug 22 16:17 bin
  7. drwxr-xr-x 3 liugang staff 96 Aug 22 16:17 boot
  8. drwxr-xr-x 6 liugang staff 192 Aug 22 16:17 conf
  9. drwxr-xr-x 90 liugang staff 2880 Aug 22 16:14 lib
  10. drwxr-xr-x 2 liugang staff 64 Aug 22 16:14 logs

 


程序pom 配置如下:

  1. <properties>
  2. <main-class>cn.rongplus.msg.Bootstrap</main-class>
  3. </properties>
  4. <build>
  5. <finalName>rongplus-receive-${project.version}</finalName>
  6. <resources>
  7. <resource>
  8. <directory>src/main/resources</directory>
  9. <filtering>true</filtering>
  10. <includes>
  11. <include>version.txt</include>
  12. <include>mapper/**/*.xml</include>
  13. <include>static/**</include>
  14. <include>templates/**</include>
  15. <include>META-INF/**</include>
  16. <include>*.xml</include>
  17. <include>*.yml</include>
  18. <include>*.properties</include>
  19. </includes>
  20. </resource>
  21. </resources>
  22. <plugins>
  23. <plugin>
  24. <groupId>org.springframework.boot</groupId>
  25. <artifactId>spring-boot-maven-plugin</artifactId>
  26. <version>${spring-boot-version}</version>
  27. <configuration>
  28. <layout>ZIP</layout>
  29. <mainClass>cn.rongplus.msg.Bootstrap</mainClass>
  30. <includes>
  31. <!-- 项目启动jar包中排除依赖包 -->
  32. <include>
  33. <groupId>non-exists</groupId>
  34. <artifactId>non-exists</artifactId>
  35. </include>
  36. </includes>
  37. </configuration>
  38. </plugin>
  39. <plugin>
  40. <groupId>org.apache.maven.plugins</groupId>
  41. <artifactId>maven-resources-plugin</artifactId>
  42. <version>2.6</version>
  43. <configuration>
  44. <encoding>${file_encoding}</encoding>
  45. </configuration>
  46. </plugin>
  47. <plugin>
  48. <groupId>org.apache.maven.plugins</groupId>
  49. <artifactId>maven-compiler-plugin</artifactId>
  50. <version>${maven_compiler_version}</version>
  51. <configuration>
  52. <source>${java_source_version}</source>
  53. <target>${java_target_version}</target>
  54. <encoding>${file_encoding}</encoding>
  55. </configuration>
  56. </plugin>
  57. <plugin>
  58. <groupId>org.apache.maven.plugins</groupId>
  59. <artifactId>maven-jar-plugin</artifactId>
  60. <version>2.4</version>
  61. <configuration>
  62. <archive>
  63. <!-- 添加maven 描述 -->
  64. <addMavenDescriptor>false</addMavenDescriptor>
  65. <manifest>
  66. <!-- 项目启动类 -->
  67. <mainClass>${main-class}</mainClass>
  68. <!-- 依赖的jar的目录前缀 -->
  69. <classpathPrefix>../lib</classpathPrefix>
  70. <addClasspath>true</addClasspath>
  71. </manifest>
  72. <manifestEntries>
  73. <!-- 此处手工将第三方依赖的jar添加到 META-INF/MANIFEST.MF 清单 多个用空格分隔 -->
  74. <Class-Path>.</Class-Path>
  75. </manifestEntries>
  76. </archive>
  77. <includes>
  78. <!-- 只打包指定目录的文件 -->
  79. <include>cn/rongplus/**</include>
  80. </includes>
  81. </configuration>
  82. </plugin>
  83. <plugin>
  84. <groupId>org.apache.maven.plugins</groupId>
  85. <artifactId>maven-assembly-plugin</artifactId>
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/307951
推荐阅读
相关标签
  

闽ICP备14008679号