maven-checkstyle-plugin error

邓鸿信
2023-12-01

1. 错误信息

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (verify) on project rocketmq-client: Failed during checkstyle execution: There are 38 errors reported by Checkstyle 6.11.2 with style/rmq_checkstyle.xml ruleset. -> [Help 1]

2. 原因

项目依赖了 maven-checkstyle-plugin插件,编译打包时会根据对应配置文件检查。很多时候从网络下载的开源项目,我们只关注能否编译过,可以将此插件去掉或者关闭,这里采用关闭的方式来解决。

3. 解决办法

3.1 方法一

maven编译的时候增加参数checkstyle.skip=true

加参数记得用D:

clean install -Dcheckstyle.skip=true

扩展
skipTests=true可以跳过执行单元测试
clean install -DskipTests=true -Dcheckstyle.skip=true

3.2 方法二

在configuration标签下,增加skip标签,跳过检查

  <plugin>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>2.17</version>
        <executions>
            <execution>
                <id>verify</id>
                <phase>verify</phase>
                <configuration>
                    <skip>true</skip>
                    <configLocation>style/rmq_checkstyle.xml</configLocation>
                    <encoding>UTF-8</encoding>
                    <consoleOutput>true</consoleOutput>
                    <failsOnError>true</failsOnError>
                    <includeTestSourceDirectory>false</includeTestSourceDirectory>
                </configuration>
                <goals>
                    <goal>check</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

clean install,就可以了。

 类似资料: