Spring Cloud Kubernetes Intellij IDEA
为了设置Intellij,您应该导入我们的编码约定,检查配置文件并设置checkstyle插件。在Spring Cloud Build 项目中可以找到以下文件。
spring-cloud-build-tools /。
└── src ├── checkstyle │ └── checkstyle-suppressions.xml └── main └── resources ├── checkstyle-header.txt ├── checkstyle.xml └── intellij ├── Intellij_Project_Defaults.xml └── Intellij_Spring_Boot_Java_Conventions.xml
- 默认抑制规则
- 文件头设置
- 默认Checkstyle规则
- 适用于大多数Checkstyle规则的Intellij项目默认值
- 适用于大多数Checkstyle规则的Intellij的项目样式约定
转到File→Settings→Editor→Code style。单击Scheme部分旁边的图标。
在那里,单击Import Scheme值,然后选择Intellij IDEA code style XML选项。导入spring-cloud-build-tools/src/main/resources/intellij/Intellij_Spring_Boot_Java_Conventions.xml文件。
转到File→Settings→Editor→Inspections。单击Profile部分旁边的图标。
在此处单击Import Profile,然后导入spring-cloud-build-tools/src/main/resources/intellij/Intellij_Project_Defaults.xml文件。
Checkstyle。 要使Intellij与Checkstyle一起使用,您必须安装Checkstyle插件。建议还安装Assertions2Assertj以自动转换JUnit断言

转到File→Settings→Other settings→Checkstyle。在Configuration file部分中单击+图标。
在这里,您必须定义应从何处选择checkstyle规则。在上图中,我们从克隆的Spring Cloud构建库中选择了规则。但是,您可以指向Spring Cloud构建的GitHub存储库(例如,对于checkstyle.xml:https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle.xml)。
我们需要提供以下变量:
checkstyle.header.file-请在克隆的存储库中或通过https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle-header.txtURL将其指向Spring Cloud构建的spring-cloud-build-tools/src/main/resources/checkstyle-header.txt文件。checkstyle.suppressions.file-默认禁止。请在克隆的存储库中或通过https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xmlURL将其指向Spring Cloud构建的spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml文件。checkstyle.additional.suppressions.file-此变量对应于本地项目中的取消显示。例如,您正在研究spring-cloud-contract。然后指向project-root/src/checkstyle/checkstyle-suppressions.xml文件夹。spring-cloud-contract的示例为:/home/username/spring-cloud-contract/src/checkstyle/checkstyle-suppressions.xml。
请记住将Scan Scope设置为All sources,因为我们将checkstyle规则应用于生产和测试源。

