1.安裝google-java-format 插件
file ->Setings... ->pligins
輸入上訴插件安裝
2.下載IntelliJ Java Google Style file文件
文件已經掛在本人博客,https://download.csdn.net/download/banana1006034246/10785007
或者官網https://github.com/google/styleguide/blob/gh-pages/intellij-java-google-style.xml
復制粘貼命名為intellij-java-google-style.xml,在IDEA中設置
file-> editor->code style 點擊右窗體里scheme后面的設置圖標,選擇import scheme找到你的xml文件,之后按提示確定就行
問題:
遇到錯誤 intellij idea code style xml import failed with error message null
原因:xml里面含有空行,這種情況常常出現在使用 linux 的wget命令下載官方xml文件導致
參考文獻
google java code style 中文版
https://github.com/google/google-java-format