我无法解决maven建筑错误失败

时间:2014-01-17 10:22:44

标签: java maven

当我使用maven构建我的项目时出现错误。请帮忙! 谢谢你的帮助

  

无法执行目标   org.apache.maven.plugins:行家组装-插件:2.2.1:装配   项目newstart-app-ithelp上的(make-assembly):执行   制作目标   org.apache.maven.plugins:maven-assembly-plugin:2.2.1:程序集失败:   对于artifact {null:null:null:jar}:groupId不能为空。原因   :执行make-assembly of goal   org.apache.maven.plugins:maven-assembly-plugin:2.2.1:程序集失败:   对于artifact {null:null:null:jar}:groupId不能为空。堆   trace:org.apache.maven.lifecycle.LifecycleExecutionException:   无法执行目标   org.apache.maven.plugins:行家组装-插件:2.2.1:装配   项目newstart-app-ithelp上的(make-assembly):执行   制作目标   org.apache.maven.plugins:maven-assembly-plugin:2.2.1:程序集失败:   对于artifact {null:null:null:jar}:groupId不能为空。

<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>

7 个答案:

答案 0 :(得分:20)

我已通过删除本地.m2/repository文件夹修复了此问题。现在构建成功了。

答案 1 :(得分:6)

我的解决方案不同。我的POM有一个<dependencyManagement>条目,其中没有任何<version>它有一个<dependencies>条目jar a <version>。此外,父POM的<dependencyManagement>条目相同<version>。显然这是混乱的Maven(3.3)。构建工作正常,但包装没有。

修复:删除子POM中的<dependencyManagement>条目,并从子POM中的<version>条目中删除<dependencies>

在代码中,这是破碎的情况:

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>

发布修复:父POM是相同的,子pom只是这个

<dependencies>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
    </dependency>
</dependencies>

答案 2 :(得分:1)

最近我遇到了同样的问题。我认为程序集插件不会传播/报告依赖项的错误:

[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]

这就是我从assembly-plugin获得的所有内容。例如。编译器警告破碎的东西:

[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

因此,如果您遇到此问题,请调用mvn dependency:tree对依赖项进行问题排查。

答案 3 :(得分:1)

如果你看看你的maven构建输出,应该有一些警告说.pom无效,传递依赖(如果有的话)将不可用。删除与这些pom相对应的所有工件并重建,您无需删除整个存储库。

答案 4 :(得分:0)

我最近在这个建筑中遇到了一个spring boot 2.2项目。 原来问题是过时的maven-assembly-plugin。我们的版本指定为2.3,但spring boot的bom至少要求3.1.1。升级到3.2.0(在撰写本文时为最新)解决了该问题。

答案 5 :(得分:0)

检查您的Maven版本。 我遇到了同样的问题,直到下载并安装了更高版本的Maven(从3.2到3.6)后,我的工作才起作用。这为我解决了这个问题。 我也在使用Java 11,从这里我可以看到: https://mkyong.com/maven/how-to-install-maven-in-windows/

Maven 3.3+ requires JDK 1.7+
Maven 3.2 requires JDK 1.6+
Maven 3.0/3.1 requires JDK 1.5+

答案 6 :(得分:0)

对我来说,暂时从插件管理部分删除以下依赖项为我解决了问题。

<plugin>
    <groupId>org.eclipse.m2e</groupId>
    <artifactId>lifecycle-mapping</artifactId>
    <version>1.0.0</version>
</plugin>

之前的错误信息:

Execution default-cli of goal org.codehaus.mojo:versions-maven-plugin:2.8.1:display-plugin-updates failed: For artifact {null:null:null:jar}: The groupId can not be empty. -> [Help 1]