首页 > 编程语言 >springboot~代码风格统计spring-javaformat-maven-plugin插件

springboot~代码风格统计spring-javaformat-maven-plugin插件

时间:2023-06-13 16:33:50浏览次数:60  
标签:插件 格式化 springboot plugin spring 代码 javaformat Spring

Spring Javaformat是Spring团队开发的一款基于Google Java Format的代码格式化工具,可以帮助Java开发者自动化进行代码格式化,提高代码质量,降低代码维护成本。

Spring Javaformat可以自定义配置文件,支持大量的代码风格配置选项,满足不同项目和团队的需求。还可以与Gradle、Maven、IntelliJ IDEA等常用开发工具集成使用,方便快速进行代码格式化。

此外,Spring Javaformat还支持CI/CD流程中的代码格式化,可以与Git、Jenkins等工具集成,确保在代码合并、构建和部署过程中,代码格式保持一致。

添加依赖

在你的基础项目的pom.xml文件中,添加javaformat的依赖

<!--代码格式插件,默认使用spring 规则 ./mvnw spring-javaformat:apply -->
<plugin>
    <groupId>io.spring.javaformat</groupId>
    <artifactId>spring-javaformat-maven-plugin</artifactId>
    <version>${spring.checkstyle.plugin}</version>
    <executions>
        <execution>
            <phase>validate</phase>
            <inherited>true</inherited>
            <goals>
                <goal>validate</goal>
            </goals>
        </execution>
    </executions>
</plugin>

代码格式化

  • 可以使用命令行工具进行格式化./mvnw spring-javaformat:apply
  • 也可以使用项目下的插件spring-javaformat:apply,如图:

标签:插件,格式化,springboot,plugin,spring,代码,javaformat,Spring
From: https://www.cnblogs.com/lori/p/17477997.html

相关文章

  • maven-compiler-plugin build-helper-maven-plugin Maven-assembly-plugin
    三个插件都是是用干啥的maven-compiler-plugin进行源代码的编译build-helper-maven-plugin项目中添加额外的资源、源代码、构建输出目录和依赖项等Maven-assembly-plugin生成可执行jar包<build><plugins><plugin><groupId......
  • springboot rabbitmq配置
    YMLrabbitmq:host:xxx.xxx.xxx.xxxport:5672virtual-host:devusername:xxxpassword:xxxpublisher-confirm-type:correlatedpublisher-returns:truelistener:direct:acknowledge-mode:autosimple:......
  • Postcat X APISIX 合作插件 :一键同步,轻松配置到 APISIX
    近日,云流科技(广州)有限公司(简称“Eolink”)旗下的开源API管理工具Postcat和深圳支流科技有限公司(简称“API7支流科技”)在各自擅长的领域携手合作,推出了Postcat&ApacheAPISIX插件,用户只需要安装此插件,即可轻松地将Postcat产品中管理的API相关配置的数据同步到开源网关......
  • 完美解决SpringBoot上传图片之后,需要重服务才能访问
    上传图片后需要重新编译才能访问图片添加一个配置文件WebMvcConfigctrl+shift+alt+/选择Registry,勾选compiler.automake.allow.when.app.running勾选添加一个配置文件WebMvcConfigpackagecom.fans.common.config;importorg.springframework.context.annotation.Configu......
  • window下正常的springboot到mac下运行却报错
    Errorcreatingbeanwithname'defaultValidator'definedinclasspathresource[org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]:Invocationofinitmethodfailed;nestedexceptionisjava.lang.NoClassDefFoun......
  • 公司已有springboot项目引入swagger
    公司已有springboot项目引入swagger1、swagger介绍官网:https://swagger.io/Swagger是一个用于生成、描述和调用RESTful接口的Web服务。通俗的来讲,Swagger就是将项目中所有(想要暴露的)接口展现在页面上,并且可以进行接口调用和测试的服务2、引入目的Swagger有以下3个重要的作......
  • 搭建springbootweb环境
    搭建springboot环境(idea环境)实现步骤:1.基础环境配置2.maven配置3.编写第一个程序helloworld(可能有两个小问题)4.运行(jar包运行,命令行运行)一.基础环境配置进入idea,点击file->new->project,在弹出的页面上,选择springinitiallzr并进行相关的配置点击next点击create,完成sp......
  • Edge浏览器的JSON格式化插件(FeHelper)不生效
    问题有时候懒得打开ApiPost测试接口,就直接使用Edge浏览器进行接口测试,但是最近格式化出了问题,FeHelper插件的JSON格式化不生效,不对,也不能说是完全不生效吧,测试非本地的接口倒是可以本地接口(奇怪的格式化,好丑......
  • eclipse 3.6.1 安装maven插件失败的解决办法
      一、eclipse3.6.1下载地址[eclipse-jee-helios-SR1-win32.zip]http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/heliossr1二、插件地址1、gef插件地址:http://download.eclipse.org/tools/gef/updates/interim/2、subclipse插件地址:http......
  • springboot 测试用例 gradle
    在springboot2.4.5之后的变成了jinut5直接引用即可不需要排除org.junit.jupiter.api.Testorg.springframework.boot:spring-boot-starter-test测试数据H2packagecom.example.test_pro_gradle;importorg.junit.jupiter.api.Test;importorg.slf4j.Logger;impor......