当前位置:   article > 正文

maven打包知识_不加repackage会默认打成jar包吗

不加repackage会默认打成jar包吗

如果在项目的pom.xml文件中没有指明打包类型,则默认打成jar包。使用maven命令  mvn clean package进行项目的打包,可看到如下输出结果:

  1. [INFO] Results:
  2. [INFO]
  3. [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
  4. [INFO]
  5. [INFO]
  6. [INFO] --- maven-jar-plugin:3.1.2:jar (default-jar) @ springboot ---
  7. [INFO] Building jar: D:\Spring\springboot\target\springboot-0.0.1-SNAPSHOT.jar
  8. [INFO]
  9. [INFO] --- spring-boot-maven-plugin:2.1.6.RELEASE:repackage (repackage) @ springboot ---
  10. [INFO] Replacing main artifact with repackaged archive
  11. [INFO] ------------------------------------------------------------------------
  12. [INFO] BUILD SUCCESS
  13. [INFO] ------------------------------------------------------------------------
  14. [INFO] Total time: 16.318 s
  15. [INFO] Finished at: 2019-07-25T22:42:05+08:00
  16. [INFO] Final Memory: 35M/252M
  17. [INFO] ------------------------------------------------------------------------

可以看到   maven-jar-plugin:3.1.2:jar (default-jar) @ springboot  其实就是利用jar插件将项目打成了springboot-0.0.1-SNAPSHOT.jar,该文件会存放在target目录下。

如果要让其他的maven项目直接引用这个jar包,还要执行mvn clean install命令,输出结果为:

  1. [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
  2. [INFO]
  3. [INFO]
  4. [INFO] --- maven-jar-plugin:3.1.2:jar (default-jar) @ springboot ---
  5. [INFO] Building jar: D:\Spring\springboot\target\springboot-0.0.1-SNAPSHOT.jar
  6. [INFO]
  7. [INFO] --- spring-boot-maven-plugin:2.1.6.RELEASE:repackage (repackage) @ springboot ---
  8. [INFO] Replacing main artifact with repackaged archive
  9. [INFO]
  10. [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ springboot ---
  11. [INFO] Installing D:\Spring\springboot\target\springboot-0.0.1-SNAPSHOT.jar to D:\Spring\maven-space
  12. \repository\com\example\springboot\0.0.1-SNAPSHOT\springboot-0.0.1-SNAPSHOT.jar
  13. [INFO] Installing D:\Spring\springboot\pom.xml to D:\Spring\maven-space\repository\com\example\sprin
  14. gboot\0.0.1-SNAPSHOT\springboot-0.0.1-SNAPSHOT.pom
  15. [INFO] ------------------------------------------------------------------------
  16. [INFO] BUILD SUCCESS
  17. [INFO] ------------------------------------------------------------------------
  18. [INFO] Total time: 18.514 s
  19. [INFO] Finished at: 2019-07-25T22:53:22+08:00
  20. [INFO] Final Memory: 35M/261M
  21. [INFO] ------------------------------------------------------------------------

在打包之后,我们又执行了安装任务install:install,从输出我们看到该任务将项目输出的jar安装到了Maven本地仓库中,我们可以打开相应的文件夹看到项目的pom和jar。只有将项目的构件安装到本地仓库之后,其他Maven项目才能使用它。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/522510
推荐阅读
相关标签
  

闽ICP备14008679号