Eclipse配置阿里Code Format - 使用阿里Java Format 模板_Raymond_Love的博客-CSDN博客
1. 配置文件下载地址
https://github.com/alibaba/p3c/tree/master/p3c-formatter
下载下面两个文件:
eclipse-codestyle.xml
eclipse-codetemplate.xml
2. 配置Eclipse
2.1 Set Window --> Preferences
2.1.1 General --> Select "Always run in background"、"Show heap status".
2.1.2 General --> Appearance --> Label Decorations
Select Java Type Indicator
2.1.3 General --> Editors --> Text Editors
Select Insert spaces for tabs、Show print margin、Show line numbers
Set Print margin column value = 120
2.1.4 General --> Workspace
Select Build automatically、Refresh using native hooks or polling;
Set Text file encoding value= UTF-8
2.1.5 Ant --> Editor --> Formatter
remove select Use tab character instead of spaces;
set Maximum line width(characters) value 120;
select Wrap long element tags ;
2.1.6 Java --> Code Style --> Code Templates
Import template: eclipse-codetemplates.xml;
Select "Automatically add comments for new methods and types"
2.1.7 Java --> Code Style --> Formatter
Import template: eclipse-codestyle.xml
2.1.8 Java --> Complier --> Errors/Warnings
Set Annotations Missing '@Override' annotation value =Error
2.1.9 Java --> Editor --> Save Actions
Select Perform the selected actions on save、Format source code,Additional actions;
Compare Additional actions, and if different, configure according to screenshots in next step:
If Additional actions are different, then configure as below screenshots
————————————————
版权声明:本文为CSDN博主「RaymondLove~」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/Emma_Love/article/details/103764936