IDEA java 代码格式化统一

Intellij idea 安装格式化插件 ECLIPSE CODE FORMATTER:
1,安装插件:
网络安装:选择Setting =>Plugins=>Browse repositories,搜索Eclipse即可出现,点击左上角的Download and Install安装。

2,配置插件:
选择Setting =>Eclipse Code Formatter,勾选Use the Eclipse-code-formatter,并在Eclipse Java Formatter config file选择Eclipse用的code-style.xml文件,这个选项会决定格式化代码的方式。


配置Import order的From File也为Eclipse用的code-style.xml文件。


3,使用插件
使用Intellij的格式化快捷键”Ctrl+ALT+L”即可进行格式化。

如果出错会输出提示到Event Log里,如果看到’xxx formatted sucessfully by Eclipse code formatter’则表示格式化成功!

原文地址:https://www.cnblogs.com/anye-15068156823/p/7200181.html