Java 我无法解决 maven 构建错误失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21183418/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
i can't solve maven building error failure
提问by user2317894
I get a error when I use maven to build my project.so please help! thank you for your help
当我使用 maven 构建我的项目时出现错误。所以请帮助!感谢您的帮助
Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2.1:assembly (make-assembly) on project newstart-app-ithelp: Execution make-assembly of goal org.apache.maven.plugins:maven-assembly-plugin:2.2.1:assembly failed: For artifact {null:null:null:jar}: The groupId cannot be empty. cause : Execution make-assembly of goal org.apache.maven.plugins:maven-assembly-plugin:2.2.1:assembly failed: For artifact {null:null:null:jar}: The groupId cannot be empty. Stack trace : org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2.1:assembly (make-assembly) on project newstart-app-ithelp: Execution make-assembly of goal org.apache.maven.plugins:maven-assembly-plugin:2.2.1:assembly failed: For artifact {null:null:null:jar}: The groupId cannot be empty.
无法在项目 newstart-app-ithelp 上执行目标 org.apache.maven.plugins:maven-assembly-plugin:2.2.1:assembly (make-assembly): 执行目标 org.apache.maven.plugins 的 make-assembly: maven-assembly-plugin:2.2.1:assembly failed: For artifact {null:null:null:jar}: groupId 不能为空。原因:目标 org.apache.maven.plugins:maven-assembly-plugin:2.2.1:assembly 的执行 make-assembly 失败:对于工件 {null:null:null:jar}:groupId 不能为空。堆栈跟踪:org.apache.maven.lifecycle.LifecycleExecutionException:无法执行目标 org.apache.maven.plugins:maven-assembly-plugin:2.2.1:assembly (make-assembly) on project newstart-app-ithelp: Execution目标 org.apache.maven.plugins:maven-assembly-plugin:2.2.1:assembly 的 make-assembly 失败:对于工件 {null:null:null:jar}:
<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">
<parent>
<groupId>com.feinno.app</groupId>
<artifactId>root-pom</artifactId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>newstart.app</groupId>
<artifactId>newstart-app-ithelp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>newstart-app-ithelp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.newstart.app.ithelp.ITHelpBean</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>assembly</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.feinno.app</groupId>
<artifactId>feinno-app-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.24</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>0.2.9</version>
</dependency>
<dependency>
<groupId>spring-aop</groupId>
<artifactId>spring-aop</artifactId>
<version>3.2.3</version>
</dependency>
<dependency>
<groupId>spring-beans</groupId>
<artifactId>spring-beans</artifactId>
<version>3.2.3</version>
</dependency>
<dependency>
<groupId>spring-context</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.3</version>
</dependency>
<dependency>
<groupId>spring-core</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.3</version>
</dependency>
<dependency>
<groupId>spring-jdbc</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.2.3</version>
</dependency>
<dependency>
<groupId>spring-tx</groupId>
<artifactId>spring-tx</artifactId>
<version>3.2.3</version>
</dependency>
<dependency>
<groupId>spring-expression</groupId>
<artifactId>spring-expression</artifactId>
<version>3.2.3</version>
</dependency>
<dependency>
<groupId>IKAnalyzer</groupId>
<artifactId>IKAnalyzer</artifactId>
<version>6</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>linq4j</groupId>
<artifactId>linq4j</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<id>snapshots</id>
<url>http://10.10.208.92:8081/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
回答by brownfox
I have fixed this issue by deleting local .m2/repository
folder. The build is successful now.
我通过删除本地.m2/repository
文件夹解决了这个问题。现在构建成功。
回答by mkhludnev
recently I stuck with the same problem. I turns that assembly-plugin doesn't propagate/report errors with dependencies:
最近我遇到了同样的问题。我认为 assembly-plugin 不会传播/报告具有依赖项的错误:
[DEBUG] Resolving project dependencies transitively.
[DEBUG] com.g.....0.4-SNAPSHOT (selected for null)
[DEBUG] org.springframework:spring-expression:jar:3.1.4.RELEASE:compile (selected for compile)
[DEBUG] org.springframework:spring-asm:jar:3.1.4.RELEASE:compile (selected for compile)
[DEBUG] trove:trove:jar:1.0.2:compile (selected for compile)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
....
[INFO] p.....mo ....................................... FAILURE [57.144s]
[INFO] BUILD FAILURE
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.5.4:single (full) on project p...o: Execution full of goal org.apache.maven.plugins:maven-assembly-plugin:2.5.4:single failed: For artifact {null:null:null:jar}: The groupId cannot be empty. -> [Help 1]
that's all what I've got from assembly-plugin. eg. compiler warns about the broken stuff:
这就是我从程序集插件中得到的。例如。编译器警告损坏的东西:
[WARNING] error reading /var/lib/jenkins/...org/hyperic/sigar/1.6.3.82/sigar-1.6.3.82.jar; error in opening zip file
[WARNING] error reading /var/lib/jenkins/.../org/hyperic/sigar/1.6.3.82/sigar-1.6.3.82.jar; error in opening zip file
Thus, if you've been stuck in this trouble, invoke mvn dependency:tree
to troubleshoot the dependency.
因此,如果您一直被困在这个麻烦中,请调用mvn dependency:tree
以解决依赖关系。
回答by Spencer
And mine has a different solution. I had a POM that had a <dependencyManagement>
entry for the jar withoutany <version>
, andit had a <dependencies>
entry for the jar witha <version>
. Plus, the parent POM had a <dependencyManagement>
entry withthe same <version>
. Apparently this confused Maven (3.3). The build worked fine, but the packaging did not.
我有一个不同的解决方案。我有一个POM是有一个<dependencyManagement>
对JAR条目没有任何<version>
,和它有一个<dependencies>
对JAR条目有一个<version>
。另外,父POM有一个<dependencyManagement>
条目与相同<version>
。显然这让 Maven (3.3) 感到困惑。构建工作正常,但包装没有。
Fix: remove <dependencyManagement>
entry in the child POM, and remove the <version>
from the <dependencies>
entry in the child POM.
修复:删除<dependencyManagement>
子 POM中的条目,并<version>
从<dependencies>
子 POM 中的条目中删除。
In code, here is the broken situation:
在代码中,这是损坏的情况:
Parent pom.xml:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
Child pom.xml:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
...
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
</dependency>
</dependencies>
Post fix: parent POM is the same, child pom has just this
后修复:父 POM 是相同的,子 POM 只有这个
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies>
回答by hpkancha
If you look at your maven build output, there should be some warnings that say .pom is invalid, transitive dependencies (if any) will not be available. Delete all the artifacts corresponding to those poms and rebuild, you need not delete the entire repository.
如果你查看你的 maven 构建输出,应该会有一些警告说 .pom 无效,传递依赖(如果有)将不可用。删除与这些 poms 对应的所有工件并重建,您不需要删除整个存储库。
回答by Paul Adamson
I recently came across this building a spring boot 2.2 project. Turns out the problem was an out of date maven-assembly-plugin. Our build specified 2.3 but spring boot's bom requested at least 3.1.1. Bumping to 3.2.0 (the latest at time of writing) fixed the problem.
我最近遇到了这个构建 spring boot 2.2 项目的项目。原来问题是一个过时的 maven-assembly-plugin。我们的构建指定了 2.3,但 spring boot 的 bom 要求至少 3.1.1。撞到 3.2.0(撰写本文时的最新版本)修复了该问题。