Spring Boot 项目完成后,准备部署到生产环境服务器。如何打包呢?
方式一:命令行
mvn clean
mvn package
方式二:IDEA IDE
IDEA 右侧有个 Maven 菜单,点开之后,双击 Lifecyle 中的 clean 和 package.
[INFO] Deleting D:\work\calf\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] Building jar: D:\work\calf\target\calf-1.0.0.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.4.0:repackage (repackage) @ calf ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
> ls -lah target/
total 50M
50M Dec 29 09:57 calf-1.0.0.jar*
20K Dec 29 09:57 calf-1.0.0.jar.original*
50M 的 jar 包 。。。
为何需要执行 mvn clean
For example: If you rename a class, the previous compiled version will remain in target/classes until you run clean. This maybe completely harmless, but it could cause issues if it is autodetected by classpath scanning and the like.
简言之就是清理 target 目录下的 class 文件缓存。防止因重命名造成的问题。
如何修改版本号
修改 pom.xml 中的 version。
参考
- https://mp.weixin.qq.com/s/wTr-8VxAnfB9VUnQO6DDxA
- https://blog.csdn.net/qq_33378853/article/details/88733165
- https://stackoverflow.com/questions/4662452/in-maven-why-run-mvn-clean
微信关注我哦 👍
我是来自山东烟台的一名开发者,有感兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式