maven 添加 checkstyle 插件约束代码规范

本例示例,是引用 http 链接这种在线 checkstyle.xml 文件的配置方式,如下示例:

xml 复制代码
    <properties>
        <maven.checkstyle.plugin.version>3.3.0</maven.checkstyle.plugin.version>
        <!--支持本地绝对路径、本地相对路径、HTTP远程路径-->
        <checkstyle.config.location>http://xxx.test.com/repository/raw-hosted/scripts/checkstyle/checkstyle.xml</checkstyle.config.location>
        <!--这样配置suppressions规则设定需要排除不检查的文件-->
        <checkstyle.suppressions.location/>
    </properties>
  
  <!--省略-->
  
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>${maven.checkstyle.plugin.version}</version>
                <configuration>
                    <consoleOutput>true</consoleOutput>
                    <violationSeverity>error</violationSeverity>
                    <detail>true</detail>
                </configuration>
                <executions>
                    <execution>
                        <id>checkstyle</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <failOnViolation>true</failOnViolation>
                            <failsOnError>false</failsOnError>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
相关推荐
这个DBA有点耶2 小时前
数据库教程:从零基础到实战的完整学习路径(2026版)
数据库·程序员·代码规范
这个DBA有点耶4 小时前
自增主键用尽了怎么办?INT溢出、在线迁移与预防策略全解析
数据库·mysql·代码规范
howard20052 天前
3.3 开发环境 - Maven
maven·安装·配置·阿里镜像源
xinjia_ctrl2 天前
暑假实习总结
git·后端·spring·maven·intellij-idea
学渣超2 天前
记一次复杂业务功能重构——从过程式长链路,到模板方法构建体系
java·架构·代码规范
网络豆2 天前
Apache Maven 鸿蒙 PC 适配全记录:把 JVM 构建工具交付到 HiShell
maven·apache·harmonyos
天涯浪客3 天前
我的漏洞扫描器,把被测项目的源码写坏了
代码规范
事圆则缓3 天前
遗留项目改造实战指南:从可读性、代码质量到性能和 AI 约束
android·ai·代码规范
乱码三千4 天前
开发了一套AI智能体协作知识体系
人工智能·架构·代码规范
sunshine22 girl4 天前
Java学习一 环境配置2 Idea的入门使用和maven配置,项目启动脚本配置
java·maven