Eclipse配置阿里Code Format - 使用阿里Java Format 模板

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 tabsShow print marginShow line numbers
  • Set Print margin column value = 120

2.1.4 General --> Workspace

  • Select Build automaticallyRefresh 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 saveFormat 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
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值