问题'packaging' with value 'jar' is invalid. 解决办法
这个问题很简单,网上也有很多的答案。以下是报错的信息:
[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 10, column 16
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project cn.xxx:1.0-SNAPSHOT (E:\das-code\spring-cloud-demo\pom.xml) has 1 error
[ERROR] 'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging. @ line 10, column 16
[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
原因分析
其原因是:当多个父-子结构的maven工程使用maven package
打包的时候, 父节点module不能把packaging 声明为jar
,应当声明为pom
,表明这是一个pom工程,不生成jar,只管理工程结构。
解决办法
将父类pom.xml中的
<packaging>jar</packaging>
改为:
<packaging>pom</packaging>
注意:子module仍然需要声明为
jar
,因为子module是实质执行代码指令的module。
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。