2013-01-24 54 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後綴。

希望這有助於一個類似的小:)