Spring Cloud Kubernetes Intellij IDEA

2024-01-08 17:39 更新

為了設(shè)置Intellij,您應(yīng)該導(dǎo)入我們的編碼約定,檢查配置文件并設(shè)置checkstyle插件。Spring Cloud Build 項(xiàng)目中可以找到以下文件。

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 
  1. 默認(rèn)抑制規(guī)則
  2. 文件頭設(shè)置
  3. 默認(rèn)Checkstyle規(guī)則
  4. 適用于大多數(shù)Checkstyle規(guī)則的Intellij項(xiàng)目默認(rèn)值
  5. 適用于大多數(shù)Checkstyle規(guī)則的Intellij的項(xiàng)目樣式約定

圖150.1 代碼風(fēng)格

代碼風(fēng)格

轉(zhuǎn)到FileSettingsEditorCode style。單擊Scheme部分旁邊的圖標(biāo)。 在那里,單擊Import Scheme值,然后選擇Intellij IDEA code style XML選項(xiàng)。導(dǎo)入spring-cloud-build-tools/src/main/resources/intellij/Intellij_Spring_Boot_Java_Conventions.xml文件。

圖150.2 檢驗(yàn)概況

代碼風(fēng)格

轉(zhuǎn)到FileSettingsEditorInspections單擊Profile部分旁邊的圖標(biāo)。 在此處單擊Import Profile,然后導(dǎo)入spring-cloud-build-tools/src/main/resources/intellij/Intellij_Project_Defaults.xml文件。

Checkstyle。 要使Intellij與Checkstyle一起使用,您必須安裝Checkstyle插件。建議還安裝Assertions2Assertj以自動(dòng)轉(zhuǎn)換JUnit斷言

Checkstyle

轉(zhuǎn)到FileSettingsOther settingsCheckstyle。Configuration file部分中單擊+圖標(biāo)。 在這里,您必須定義應(yīng)從何處選擇checkstyle規(guī)則。在上圖中,我們從克隆的Spring Cloud構(gòu)建庫中選擇了規(guī)則。但是,您可以指向Spring Cloud構(gòu)建的GitHub存儲(chǔ)庫(例如,對(duì)于checkstyle.xmlhttps://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle.xml)。 我們需要提供以下變量:

請(qǐng)記住將Scan Scope設(shè)置為All sources,因?yàn)槲覀儗heckstyle規(guī)則應(yīng)用于生產(chǎn)和測(cè)試源。
以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)