maven-jacoco-plugin:添加类排除后构建失败

时间:2017-08-17 20:01:16

标签: java maven

我正在使用maven jacoco插件进行代码覆盖。我决定从jacoco报道中排除一些课程。我找到了here,怎么做。

所以我更新的pom文件如下所示:

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

    <artifactId>payment-rest</artifactId>
    <packaging>war</packaging>

    <name>payment-rest</name>

    <parent>
        <artifactId>payment-ws</artifactId>
        <groupId>com.example.foo</groupId>
        <version>1.0.0-INTEGRATION-SNAPSHOT</version>
    </parent>

    <properties>
        <jacoco.line.coverage>0.78</jacoco.line.coverage>
        <jacoco.branch.coverage>1.00</jacoco.branch.coverage>
        <servlet.version>3.0.1</servlet.version>
    </properties>

    <dependencies>

     <!-- all dependecies here-->
    </dependencies>

    <build>
        <finalName>payment-ws</finalName>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>sonar-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            **/com/example/foo/payment/configuration/**.*
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <attachClasses>true</attachClasses>
                    <classesClassifier>classes</classesClassifier>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

因此,当我运行mvn clean install命令时,我收到此错误():

Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19:test failed: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?

enter image description here

如果我删除了排除部分,则项目构建成功。

有人可以告诉我如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

发生

问题是因为您的项目maven-surefire-plugin中缺少pom.xml。在添加需要更新和重建项目并运行它之后,您需要将此plugin添加到pom.xml

你可以在下面找到maven插件:

 <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.19.1</version>
        </plugin>
  </plugins>

您可以参考2.19.1的更高版本。