0

在一个 Maven 项目中,我试图添加插件以进行代码覆盖并在 pom.xml 中查找错误,我已经粘贴了错误跟踪。如果我删除插件它工作正常。有什么建议么?

pom.xml

<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">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.clusters.demo</groupId>
  <artifactId>webservice-demo</artifactId>
  <version>1</version>
  <packaging>war</packaging>

  <name>demo</name>
  <url>http://maven.apache.org</url>

  <build>
  <plugins>
      <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>findbugs-maven-plugin</artifactId>
          <version>2.4.0</version>
          <configuration>
              <effort>Max</effort>
              <failOnError>true</failOnError>
              <threshold>High</threshold>
              <xmlOutput>true</xmlOutput>
          </configuration>
          <executions>
              <execution>
                  <id>findbugs-report</id>
                  <phase>package</phase>
                  <goals>
                      <goal>findbugs</goal>
                  </goals>
              </execution>
          </executions>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>  
                <formats>
                    <format>html</format>
                    <format>xml</format>  
                </formats>  
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>cobertura</goal>  
                    </goals>  
                </execution>  
            </executions>  
        </plugin>
  </plugins>
</build>


    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <repositories>
        <repository>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>maven-central</id>
            <url>some url</url>
        </repository>
        <repository>
            <releases>
                <enabled>false</enabled>
            </releases>
            <id>maven-snapshots</id>
            <url>some url</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.5.6-Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.0.1.Final</version>
            <!--scope>provided</scope -->
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.2.0.Final</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.1.1.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>3.1.1.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>3.1.1.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-hibernate3</artifactId>
            <version>2.0.8</version>
        </dependency>

        <!--dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-orm</artifactId>
          <version>3.1.1.RELEASE</version>
        </dependency-->

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>3.1.1.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-asm</artifactId>
            <version>3.1.1.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>3.1.1.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>3.1.1.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.1.1.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>3.1.1.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>3.1.1.RELEASE</version>
        </dependency>

        <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-oxm</artifactId>
         <version>3.1.1.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.4</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.8</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.5.8</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc14</artifactId>
            <version>10.2.0.1.0</version>
        </dependency>

        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.1</version>
        </dependency>

        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.8.1</version>
        </dependency>

        <dependency>
          <groupId>commons-lang</groupId>
          <artifactId>commons-lang</artifactId>
          <version>2.4</version>
        </dependency>

        <dependency>
          <groupId>org.freemarker</groupId>
          <artifactId>freemarker</artifactId>
          <version>2.3.19</version>
        </dependency>
    </dependencies>
</project>

错误 -

[ERROR] Failed to execute goal on project demo-webservice: Could not re
solve dependencies for project com.clusters.demo:demo-webservice:war:1: Cou
ld not find artifact org.springframework:spring-aop:jar:3.0.0.RC3 in maven-centr
al ( some url ) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyReso
lutionException
4

3 回答 3

0

我不知道 findbugs 和 cobertura 插件可以在包阶段运行吗?这些是通常在站点创建中运行的报告插件。项目构建和站点的生命周期不同:http ://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference

由于这两个报告(findbugs 和 cobertura)都需要相当长的时间,我不会在打包阶段运行它们。

通常您将它们配置为报告插件并使用以下方式运行它们mvn site:请参阅http://mojo.codehaus.org/findbugs-maven-plugin/usage.html cobertura 插件(奇怪?)未配置为报告插件: http:// mojo.codehaus.org/cobertura-maven-plugin/usage.html

但没有配置阶段。这可能会导致邪恶。

你得到的错误:Could not find artifact org.springframework:spring-aop:jar:3.0.0.RC3有点奇怪,因为上面的 pom 中的依赖项有不同的版本。此外,pom 和错误消息中的 artifactId 也不同(demo-webservice 与 webservice-demo)。这些项目是否相关?执行mvn dependency:tree以找出 aop 3.0.0.RC3 版本的来源。

并且请把版本改成1-SNAPSHOT,否则maven认为是发布版(没有-SNAPSHOT后缀。

希望这有一点帮助:)

于 2013-01-24T10:56:17.270 回答
0

尝试这个

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-aop</artifactId>
  <version>3.0.0.RC3</version>
</dependency>

一切顺利

于 2013-01-24T10:53:22.647 回答
0

我认为您的 Spring 依赖项之一需要 spring-aop:3.0.0.RC3 您有 2 个可能性: 1. 尝试找出在哪里并排除它。2.org.springframework spring-aop 3.0.0.RC3

maven-central 中的工件 org.springframework:spring-aop:jar:3.0.0.RC3 ( some url ) maven 在存储库中找不到您正在寻找的依赖项。如果您有自己的存储库服务器,请尝试在其上下载/上传

于 2013-01-24T10:53:26.420 回答