2013-01-24 43 views
0

在maven项目中,我试图添加代码覆盖的插件并在pom.xml中查找错误,我粘贴了错误跟踪。如果我删除插件,它工作正常。 有什么建议吗?如何添加Maven插件 - 查找错误,代码覆盖率

的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 
+0

我面临的问题http://stackoverflow.com/questions/9751219/why-does-maven-download-different-versions-of-spring-artifacts现在它是固定的 –

回答

0

试试这个

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

一切顺利

0

我觉得你的春天的一个依赖需要弹簧AOP :3.0.0.RC3 您有两种可能性: 1.尝试找出并排除它。 2. org.springframework 弹簧的AOP 3.0.0.RC3

工件org.springframework:弹簧AOP:罐:3.0.0.RC3在行家 - 中心(一些URL)的行家能找不到您在存储库中寻找的依赖关系。如果你有自己的资源库服务器,请尝试下载/上传它

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中的依赖关系具有不同的版本。此外,artifactId在pom和错误消息中是不同的(demo-webservice vs webservice-demo)。这些项目是相关的吗? 执行mvn dependency:tree来找出aop 3.0.0.RC3版本来自哪里。

并请更改版本1 - 快照,否则行家认为这是一个发布版本(无-SNAPSHOT后缀。

希望这有助于一个类似的小:)