1.打开eclipse 2.使用快捷键 Ctrl+shift+f 3.或者设置eclipse Project → Properties → Java Code Style → Formatter 即可完成格式化