Maven 打包问题「建议收藏」

Maven 打包问题「建议收藏」Maven打包问题1、问题描述2、问题分析3、问题解决4、总结1、问题描述今天给聚合工程统一打包时出现这样一个异常packaging’withvalue’jar’isinvalid.Aggregatorprojectsrequire’pom’aspackaging.@line4,column109。完整异常如下:[INFO]Scanningforpro…

大家好,又见面了,我是你们的朋友全栈君。

1、问题描述

今天给聚合工程统一打包时出现这样一个异常packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging. @ line 4, column 109。完整异常如下:

[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging. @ line 4, column 109
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project cn.edu.njust:mango_pom:1.0-SNAPSHOT (D:\nanligong\mianshi\project\20200505\fuxi\springcloudproject\mongo_back02\mango_pom\pom.xml) has 1 error
[ERROR]     'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging. @ line 4, column 109
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

Process finished with exit code 1

2、问题分析

出错的pom.xml文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>cn.edu.njust</groupId>
    <artifactId>mango_pom</artifactId>
    <version>1.0-SNAPSHOT</version>

    <modules>
        <module>../mango_common</module>
        <module>../mango_core</module>
        <module>../mango</module>
    </modules>

</project>

  这是由于统一打包的工程不生成jar包文件,所以需要使用pom格式打包,即<packaging>pom</packaging>。完整正确pom.xml文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <packaging>pom</packaging>

    <groupId>cn.edu.njust</groupId>
    <artifactId>mango_pom</artifactId>
    <version>1.0-SNAPSHOT</version>

    <modules>
        <module>../mango_common</module>
        <module>../mango_core</module>
        <module>../mango</module>
    </modules>

</project>

3、问题解决

运行程序,结果输出如下:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] mango-common                                                       [jar]
[INFO] mango_core                                                         [jar]
[INFO] mango                                                              [jar]
[INFO] mango_pom                                                          [pom]
[INFO] 
[INFO] ---------------------< cn.edu.njust:mango-common >----------------------
[INFO] Building mango-common 1.0-SNAPSHOT                                 [1/4]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ mango-common ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ mango-common ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ mango-common ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\nanligong\mianshi\project\20200505\fuxi\springcloudproject\mongo_back02\mango_common\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ mango-common ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ mango-common ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ mango-common ---
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ mango-common ---
[INFO] Installing D:\nanligong\mianshi\project\20200505\fuxi\springcloudproject\mongo_back02\mango_common\target\mango-common-1.0-SNAPSHOT.jar to D:\nanligong\program\java\maven\repos\cn\edu\njust\mango-common\1.0-SNAPSHOT\mango-common-1.0-SNAPSHOT.jar
[INFO] Installing D:\nanligong\mianshi\project\20200505\fuxi\springcloudproject\mongo_back02\mango_common\pom.xml to D:\nanligong\program\java\maven\repos\cn\edu\njust\mango-common\1.0-SNAPSHOT\mango-common-1.0-SNAPSHOT.pom
[INFO] 
[INFO] ----------------------< cn.edu.njust:mango_core >-----------------------
[INFO] Building mango_core 1.0-SNAPSHOT                                   [2/4]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ mango_core ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ mango_core ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ mango_core ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\nanligong\mianshi\project\20200505\fuxi\springcloudproject\mongo_back02\mango_core\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ mango_core ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ mango_core ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ mango_core ---
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ mango_core ---
[INFO] Installing D:\nanligong\mianshi\project\20200505\fuxi\springcloudproject\mongo_back02\mango_core\target\mango_core-1.0-SNAPSHOT.jar to D:\nanligong\program\java\maven\repos\cn\edu\njust\mango_core\1.0-SNAPSHOT\mango_core-1.0-SNAPSHOT.jar
[INFO] Installing D:\nanligong\mianshi\project\20200505\fuxi\springcloudproject\mongo_back02\mango_core\pom.xml to D:\nanligong\program\java\maven\repos\cn\edu\njust\mango_core\1.0-SNAPSHOT\mango_core-1.0-SNAPSHOT.pom
[INFO] 
[INFO] -------------------------< cn.edu.njust:mango >-------------------------
[INFO] Building mango 0.0.1-SNAPSHOT                                      [3/4]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ mango ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 12 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ mango ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ mango ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\nanligong\mianshi\project\20200505\fuxi\springcloudproject\mongo_back02\mango\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ mango ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ mango ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-jar-plugin:3.1.2:jar (default-jar) @ mango ---
[INFO] Building jar: D:\nanligong\mianshi\project\20200505\fuxi\springcloudproject\mongo_back02\mango\target\mango-0.0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.2.6.RELEASE:repackage (repackage) @ mango ---
[INFO] Replacing main artifact with repackaged archive
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ mango ---
[INFO] Installing D:\nanligong\mianshi\project\20200505\fuxi\springcloudproject\mongo_back02\mango\target\mango-0.0.1-SNAPSHOT.jar to D:\nanligong\program\java\maven\repos\cn\edu\njust\mango\0.0.1-SNAPSHOT\mango-0.0.1-SNAPSHOT.jar
[INFO] Installing D:\nanligong\mianshi\project\20200505\fuxi\springcloudproject\mongo_back02\mango\pom.xml to D:\nanligong\program\java\maven\repos\cn\edu\njust\mango\0.0.1-SNAPSHOT\mango-0.0.1-SNAPSHOT.pom
[INFO] 
[INFO] -----------------------< cn.edu.njust:mango_pom >-----------------------
[INFO] Building mango_pom 1.0-SNAPSHOT                                    [4/4]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ mango_pom ---
[INFO] Installing D:\nanligong\mianshi\project\20200505\fuxi\springcloudproject\mongo_back02\mango_pom\pom.xml to D:\nanligong\program\java\maven\repos\cn\edu\njust\mango_pom\1.0-SNAPSHOT\mango_pom-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] mango-common ....................................... SUCCESS [  1.477 s]
[INFO] mango_core ......................................... SUCCESS [  0.045 s]
[INFO] mango 0.0.1-SNAPSHOT ............................... SUCCESS [  3.562 s]
[INFO] mango_pom 1.0-SNAPSHOT ............................. SUCCESS [  0.009 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.091 s
[INFO] Finished at: 2020-05-06T13:06:40+08:00
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "nexus" could not be activated because it does not exist.

Process finished with exit code 0

打包成功!

4、总结

  书上的代码直接运行绝大部分是对的,但是总有一些软件的更新使得作者无能为力。之前的API是对的,但是之后就废弃了或修改了是常有的事。所以我们需要跟踪源代码。这只是一个小小的问题,如果没有前辈的无私奉献,很难想象我们自己一天能学到多少内容。感谢各位前辈的辛勤付出,让我们少走了很多的弯路!

点个赞再走呗!欢迎留言哦!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/142860.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • setproperty java_Java中System.setProperty()的用法

    setproperty java_Java中System.setProperty()的用法该方法的作用是:设置指定键指示的系统属性在实际项目中发现,如果一个服务器下放置了多个web项目的话,在一个项目中通过调用System.setProperty设置了某个值,再另一个项目中也能获取到该值,所以如果想在一个项目中设置全局变量时尽量避免使用这个方法,应该调用相应的appContext。/**设置指定键对值的系统属性*setProperty(Stringprop,Stringva…

    2022年7月12日
    18
  • 毕业设计之我的项目—-旅游管理系统的设计与实现[通俗易懂]

    毕业设计之我的项目—-旅游管理系统的设计与实现[通俗易懂]本项目需求来源于网络,有需要源码和交流的评论额?喜欢软件对软件有着很高程度认识的朋友也可以指出我的设计问题等等。欢迎与我交流角色分析角色:用户:管理员:功能分析用户:登录注册:修改个人信息预定酒店功能个人酒店订单查询:景点信息查询:酒店评价:景点评价:游记功能:增-查线路查询:轮播图:结伴游:…

    2022年6月3日
    48
  • servlet到底是什么?[通俗易懂]

    servlet到底是什么?[通俗易懂]servlet到底是什么?对于这个问题一直云里雾里的,今天打算刨根问底。一、Servlet简介  Servlet是sun公司提供的一门用于开发动态web资源的技术。  Sun公司在其API中提供了一个servlet接口,用户若想用发一个动态web资源(即开发一个Java程序向浏览器输出数据),需要完成以下2个步骤:  1、编写一个Java类,实现servlet接口。

    2022年6月25日
    27
  • printer和typewriter_java类中可以定义类吗

    printer和typewriter_java类中可以定义类吗打印流       字符打印流(针对文本进行操作:PrintWriter)       字节打印流(PrintStream和标准输出流有关系System.out;)   PrintWriter:属于输出流 1)只能写数据(只能针对目的地文件进行操作),不能读数据(不能针对源文件进行操作) 2)可以针对文件直接进行操作  如果一个类中的构造方法里面有File对象或者String类型数…

    2022年8月10日
    10
  • Python 实现毫秒级淘宝抢购脚本

    Python 实现毫秒级淘宝抢购脚本本篇文章主要介绍了Python通过selenium实现毫秒级自动抢购的示例代码,通过扫码登录即可自动完成一系列操作,抢购时间精确至毫秒,可抢加购物车等待时间结算的,也可以抢聚划算的商品。博主不提供任何服务器端程序,也不提供任何收费抢购软件。该文章仅作为学习selenium框架的一个示例代码。该思路可运用到其他任何网站,京东,天猫,淘宝均可使用,且不属于外挂或者软件之类,只属于一个自动化点击工…

    2022年4月28日
    210
  • setscale方法的用法_基于BigDecimal.setScale的用法小结

    setscale方法的用法_基于BigDecimal.setScale的用法小结1.BigDecimalnum1=newBigDecimal(2.225667);//这种写法不允许,会造成精度损失2.BigDecimalnum2=newBigDecimal(2);//这种写法是可以的3.BigDecimalnum=newBigDecimal(“2.225667”);//一般都会这样写最好4.intcount=num.scale();Sys…

    2022年10月20日
    1

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号