W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
為了設(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
轉(zhuǎn)到File
→Settings
→Editor
→Code 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
文件。
轉(zhuǎn)到File
→Settings
→Editor
→Inspections
。單擊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斷言
轉(zhuǎn)到File
→Settings
→Other settings
→Checkstyle
。在Configuration file
部分中單擊+
圖標(biāo)。
在這里,您必須定義應(yīng)從何處選擇checkstyle規(guī)則。在上圖中,我們從克隆的Spring Cloud構(gòu)建庫中選擇了規(guī)則。但是,您可以指向Spring Cloud構(gòu)建的GitHub存儲(chǔ)庫(例如,對(duì)于checkstyle.xml
:https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle.xml
)。
我們需要提供以下變量:
checkstyle.header.file
-請(qǐng)?jiān)诳寺〉拇鎯?chǔ)庫中或通過https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle-header.txt
URL將其指向Spring Cloud構(gòu)建的spring-cloud-build-tools/src/main/resources/checkstyle-header.txt
文件。
checkstyle.suppressions.file
-默認(rèn)禁止。請(qǐng)?jiān)诳寺〉拇鎯?chǔ)庫中或通過https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml
URL將其指向Spring Cloud構(gòu)建的spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml
文件。
checkstyle.additional.suppressions.file
-此變量對(duì)應(yīng)于本地項(xiàng)目中的取消顯示。例如,您正在研究spring-cloud-contract
。然后指向project-root/src/checkstyle/checkstyle-suppressions.xml
文件夾。
spring-cloud-contract
的示例為:/home/username/spring-cloud-contract/src/checkstyle/checkstyle-suppressions.xml
。請(qǐng)記住將Scan Scope
設(shè)置為All sources
,因?yàn)槲覀儗heckstyle規(guī)則應(yīng)用于生產(chǎn)和測(cè)試源。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: