繁体   English   中英

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

[英]maven-jacoco-plugin: Build fails after adding class excluding

我正在使用maven jacoco插件进行代码覆盖。 我决定从jacoco覆盖率报告中排除一些班级。 我在这里找到 ,怎么做。

所以我更新的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?

在此处输入图片说明

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

有人可以建议我如何解决这个问题吗?

发生问题是因为您的项目pom.xml缺少maven-surefire-plugin 您需要在添加需要更新和重建项目并运行它之后,将该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更高版本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM