Couldn't run build using Maven because of an e

2020-07-08 06:37发布

问题:

I am trying to build a new Maven project in Eclipse. In my pom.xml, I got an error which says

Multiple annotations found at this line: - Missing artifact maven-plugins:maven-findbugs-plugin:plugin:1.3.1 - Missing artifact maven-plugins:maven-cobertura-plugin:plugin:1.3

Here is my dependency code for "cobertura" in pom.xml:

   <dependency>
        <groupId>maven-plugins</groupId>
        <artifactId>maven-cobertura-plugin</artifactId>
        <version>1.3</version>
        <type>plugin</type>
    </dependency>

I tried adding repositories as below, but still didn't work.

  <repositories>
    <repository>
        <id>repository.maven-plugins.sourceforge.net</id>
        <name>maven plug-in repository</name>
        <url>http://maven-plugins.sourceforge.net/repository</url>
    </repository>
    <repository>
        <id>repository.ibiblio.org-maven</id>
        <name>ibiblio repository</name>
        <url>http://www.ibiblio.org/maven</url>
    </repository>
</repositories>

Links to Maven plugins here
http://maven-plugins.sourceforge.net/maven-findbugs-plugin/announcements/announcement-1.3.1.txt

http://maven-plugins.sourceforge.net/maven-cobertura-plugin/announcements/announcement-1.3.txt

I don't want to do Manual installation for these plugins. I need to install them automatically by declaring them in pom.xml

Please help.

Thanks

回答1:

As a related issue, I found that e.g. jaxen-1.1.3 references the above maven1 artifacts. The POM editor in Eclipse shows you the dependency hierarchy. It added the following for selecting explicit excludes:

    <dependency>
        <groupId>jaxen</groupId>
        <artifactId>jaxen</artifactId>
        <version>1.1.3</version>
        <exclusions>
            <exclusion>
                <artifactId>maven-cobertura-plugin</artifactId>
                <groupId>maven-plugins</groupId>
            </exclusion>
            <exclusion>
                <artifactId>maven-findbugs-plugin</artifactId>
                <groupId>maven-plugins</groupId>
            </exclusion>
        </exclusions>
    </dependency>


回答2:

These are maven 1 plugins and will not work with maven 2. These are the current versions of the plugins.

  • cobertura maven plugin 2.5.1
  • findbugs maven plugin 2.3.3

You would define plugins within <plugins> tag and not <dependencies> tag. Also note the change in groupId and artifactId for these plugins below...

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <version>2.5.1</version>   
 </plugin>

 <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>findbugs-maven-plugin</artifactId>
    <version>2.3.3</version>    
  </plugin>