JeeGit 官方论坛

找回密码
立即注册
搜索
热搜: 活动 交友 discuz
发新帖

1

收听

0

听众

192

主题
发表于 2023-12-6 15:57:33 | 查看: 158| 回复: 0
【springboot开发】项目打包、发布和部署


https://blog.csdn.net/idiotyi/article/details/131383105


【springboot开发】项目打包、发布和部署


  1. 前言:可以打包成JAR包独立运行,也可以打包成WAR包部署到Tomcat容器中,若涉及到大规模部署,Jenkins成为最佳选择之一。本文主要介绍Maven项目的打包、发布和部署。
复制代码

  1. <build>
  2.                 <!--打包后的项目名称 -->
  3.                 <finalName>fast-v${fast.version}-${build.time}</finalName>
  4.                 <plugins>
  5.                         <!-- 生成打包时间使用GMT+8 -->
  6.                         <plugin>
  7.                                 <groupId>org.codehaus.mojo</groupId>
  8.                                 <artifactId>build-helper-maven-plugin</artifactId>
  9.                                 <executions>
  10.                                         <execution>
  11.                                                 <id>timestamp-property</id>
  12.                                                 <goals>
  13.                                                         <goal>timestamp-property</goal>
  14.                                                 </goals>
  15.                                                 <configuration>
  16.                                                         <name>build.time</name>
  17.                                                         <pattern>yyyyMMdd</pattern>
  18.                                                         <timeZone>GMT+8</timeZone>
  19.                                                 </configuration>
  20.                                         </execution>
  21.                                 </executions>
  22.                         </plugin>

  23.                         <!-- 单元测试-->
  24.                         <plugin>
  25.                                 <groupId>org.apache.maven.plugins</groupId>
  26.                                 <artifactId>maven-surefire-plugin</artifactId>
  27.                                 <!-- 指定版本,2.22.2 版本导致不执行-->
  28.                                 <version>2.19.1</version>
  29.                                 <configuration>
  30.                                         <includes>
  31.                                                 <include>**/RunTest.java</include>
  32.                                         </includes>
  33.                                         <excludes>
  34.                                                 <exclude>**/test/Encode*.java</exclude>
  35.                                                 <exclude>**/test/Init*.java</exclude>
  36.                                         </excludes>
  37.                                 </configuration>
  38.                         </plugin>

  39.                         <!-- java编译插件 -->
  40.                         <plugin>
  41.                                 <groupId>org.apache.maven.plugins</groupId>
  42.                                 <artifactId>maven-compiler-plugin</artifactId>
  43.                                 <configuration>
  44.                                         <encoding>${project.build.sourceEncoding}</encoding>
  45.                                 </configuration>
  46.                         </plugin>

  47.                         <!-- 打jar包的插件 -->
  48.                         <plugin>
  49.                                 <groupId>org.apache.maven.plugins</groupId>
  50.                                 <artifactId>maven-jar-plugin</artifactId>
  51.                                 <configuration>
  52.                                         <archive>
  53.                                                 <manifest>
  54.                                                         <addClasspath>true</addClasspath>
  55.                                                         <classpathPrefix>lib</classpathPrefix>
  56.                                                         <!-- 程序启动入口 -->
  57.                                                         <mainClass>com.j2eefast.FastApplication</mainClass>
  58.                                                 </manifest>
  59.                                                 <manifestEntries>
  60.                                                         <Class-Path>./</Class-Path>
  61.                                                 </manifestEntries>
  62.                                         </archive>

  63.                                         <!-- 不打包资源文件(配置文件和依赖包分开)-->
  64.                                         <excludes>
  65.                                                 <exclude>config/**</exclude>
  66.                                                 <exclude>static/**</exclude>
  67.                                                 <exclude>public/**</exclude>
  68.                                                 <exclude>mapper/**</exclude>
  69.                                                 <exclude>templates/**</exclude>
  70.                                                 <exclude>i18n/**</exclude>
  71.                                                 <exclude>*.yml</exclude>
  72.                                                 <exclude>*.txt</exclude>
  73.                                                 <exclude>*.xml</exclude>
  74.                                                 <exclude>*.pfx</exclude>
  75.                                                 <exclude>*.bat</exclude>
  76.                                                 <exclude>*.sh</exclude>
  77.                                                 <exclude>build/**</exclude>
  78.                                                 <exclude>*.properties</exclude>
  79.                                                 <exclude>license/**</exclude>
  80.                                                 <exclude>ehcache/**</exclude>
  81.                                                 <exclude>run/**</exclude>
  82.                                         </excludes>
  83.                                 </configuration>
  84.                         </plugin>

  85.                         <!-- 需要打成完整gz包放开注解
  86.                         <plugin>
  87.                                 <artifactId>maven-assembly-plugin</artifactId>
  88.                                 <configuration>
  89.                                         <appendAssemblyId>false</appendAssemblyId>
  90.                                         <descriptors>
  91.                                                 <descriptor>src/main/build/package.xml</descriptor>
  92.                                         </descriptors>
  93.                                 </configuration>
  94.                                 <executions>
  95.                                         <execution>
  96.                                                 <id>make-assembly</id>
  97.                                                 <phase>package</phase>
  98.                                                 <goals>
  99.                                                         <goal>single</goal>
  100.                                                 </goals>
  101.                                         </execution>
  102.                                 </executions>
  103.                         </plugin>
  104.                          -->
  105.                 </plugins>
  106.         </build>
复制代码




您需要登录后才可以回帖 登录 | 立即注册

QQ|Archiver|手机版|小黑屋|JeeGit 官方论坛 ( 吉ICP备19001578号-2|吉B2-20200006 )

GMT+8, 2024-4-25 15:09 , Processed in 0.027916 second(s), 17 queries .

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表