Maven checkstyle使用错误的样式

问题描述 投票:2回答:1

我在pom.xml中具有以下配置:

<reporting>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-checkstyle-plugin</artifactId>
      <version>2.17</version>
      <configuration>
        <configLocation>google_checks.xml</configLocation>
        <failOnViolation>true</failOnViolation>
        <enableFilesSummary>false</enableFilesSummary>
      </configuration>
    </plugin>
  </plugins>
</reporting>

设置为使用Google编码样式,但是使用sun_checks.xml文件(此插件的默认设置:]

mvn checkstyle:check | grep sun
[INFO] There are 913 errors reported by Checkstyle 8.19 with sun_checks.xml ruleset.

我的POM配置有什么问题?

谢谢你。

maven checkstyle
1个回答
3
投票
配置应该在<build>中,而不是在<reporting>中:

<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.17</version> <configuration> <configLocation>google_checks.xml</configLocation> <encoding>UTF-8</encoding> <consoleOutput>true</consoleOutput> <failsOnError>true</failsOnError> </configuration> <executions> <execution> <id>validate</id> <phase>validate</phase> <goals> <goal>check</goal> </goals> </execution> </executions> </plugin> </plugins> </build>

© www.soinside.com 2019 - 2024. All rights reserved.