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是对的,但是之后就废弃了或修改了是常有的事。所以我们需要跟踪源代码。这只是一个小小的问题,如果没有前辈的无私奉献,很难想象我们自己一天能学到多少内容。感谢各位前辈的辛勤付出,让我们少走了很多的弯路!

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

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

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

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • oracle存储过程相关整理

    oracle存储过程相关整理存储过程:存储过程是 SQL, PL/SQL, Java 语句的组合, 它使你能将执行商业规则的代码从你的应用程序中移动到数据库。这样的结果就是,代

  • AWVS简单操作[通俗易懂]

    AWVS简单操作[通俗易懂]AWVS简单介绍AcunetixWebVulnerabilityScanner(简称AWVS)是一款知名的网络漏洞扫描工具,它通过网络爬虫检查SQL注入攻击漏洞、XSS跨站脚本攻击漏洞等漏洞检测流行安全漏洞,来审核Web应用程序的安全性。但有些漏洞,还是扫不出来的,比如:逻辑漏洞、一些较隐蔽的XSS和SQL注入。所以,渗透的时候,工具一般都是需要人员来配合使用的。AWVS官方网站是:…

  • prophet Seasonality, Holiday Effects, And Regressors季节性,假日效应和回归[通俗易懂]

    prophet Seasonality, Holiday Effects, And Regressors季节性,假日效应和回归[通俗易懂]例子代码https://github.com/lilihongjava/prophet_demo/tree/master/seasonality_holiday_effects__regressors一、假期和特殊事件建模如果有假期或其他想要建模的重复事件,则必须为它们创建dataframe。对于dataframe,每个假期一行有两列(holiday节假日和ds日期戳)。它必须包括所有…

  • STM32学习笔记之—红外通信

    STM32学习笔记之—红外通信132

    2022年10月28日
  • 安装petalinux总是提示paytho_archlinux安装教程

    安装petalinux总是提示paytho_archlinux安装教程参考教程:Confluence1.准备工作:硬件材料:XilinxZCU106套件一套 16G的SD卡一个 网线一根 MicroUSB线一根 HDMI线一根 USB键盘、鼠标各一个软件材料: UbuntuSource:https://www.xilinx.com/member/forms/download/design-license-xef.html?akdm=0&filename=Ubuntu_Source_Release.zip Petalinu

  • 起名字、三个字母任意组合,一共有17576种组合

    起名字、三个字母任意组合,一共有17576种组合$arr=array();$str=”abcdefghijklmnopqrstuvwxyz”;for($i=0;$i<strlen($str);$i++){for($j=0;$j<strlen($str);$j++){for($k=0;$k<strlen($str);$k++){array_push($arr,$str[$i].$str[$j].$str[$k]);.

发表回复

您的电子邮箱地址不会被公开。

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