i can't solve maven building error failure

后端 未结 6 1061
粉色の甜心
粉色の甜心 2021-01-11 10:46

I get a error when I use maven to build my project.so please help! thank you for your help

Failed to execute goal org.apache.maven.plugins:maven-ass

相关标签:
6条回答
  • 2021-01-11 11:01

    Check your Maven version. I had the same problem and nothing worked until I downloaded and installed a later version of Maven (from 3.2 to 3.6). This solved the issue for me. Also I was using Java 11 and from what I see here: 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+
    
    0 讨论(0)
  • 2021-01-11 11:05

    And mine has a different solution. I had a POM that had a <dependencyManagement> entry for the jar without any <version>, and it had a <dependencies> entry for the jar with a <version>. Plus, the parent POM had a <dependencyManagement> entry with the same <version>. Apparently this confused Maven (3.3). The build worked fine, but the packaging did not.

    Fix: remove <dependencyManagement> entry in the child POM, and remove the <version> from the <dependencies> entry in the child 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

    <dependencies>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
        </dependency>
    </dependencies>
    
    0 讨论(0)
  • 2021-01-11 11:06

    recently I stuck with the same problem. I turns that assembly-plugin doesn't propagate/report errors with dependencies:

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

    0 讨论(0)
  • 2021-01-11 11:08

    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.

    0 讨论(0)
  • 2021-01-11 11:11

    I have fixed this issue by deleting local .m2/repository folder. The build is successful now.

    0 讨论(0)
  • 2021-01-11 11:14

    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.

    0 讨论(0)
提交回复
热议问题