开发环境配置-eclipse统一格式-1

w3c的eclipse教程手册 点这里
eclipse菜鸟教程 参考手册

JDK

统一安装版本:JDK7

Eclipse设置

为避免因每个人开发环境设置不同,造成修改代码文件的空格换行等不一致,难以对比历史版本的问题。对开发环境设置进行统一。
推荐使用JavaEE版eclipse,下载地址:
win32版
win64版
linux64版

下面设置基本都在Window->Preferences 中进行

  1. 设置编码、缩进换行符(非常重要!影响git diff效果)

    Window–>Preferences–>General–>Workspace 中Text file encoding设为UTF-8,New text file line delimiter 设为Unix
    Window–>Preferences–>General–>Editors–>Text Editors 右边的选项Insert spaces for tabs 勾上!然后 Displayed tab width =4

  2. 设置保存java文件时动作

    Java -> Editor -> Save Actions 勾选 Format source code(Format all lines)和Organize imports

  3. 设置使用JDK

    Java->Install JREs,勾选已安装的JDK(而不是 JRE)的目录为默认,否则看不到JDK自己的源码,而且Jetty编译JSP失败
    选择已安装的JDK,点击Edit,Default VM Arguments输入:-Duser.timezone=GMT+08

  4. 调整Java和XML的宽度到120,调整缩进符

    Java->Code Style->Formatter, 基于Eclipse-Buildin new 一个出来,点击Edit,标签Line Wrapping和Comments里的Maximum Line Width 设置为120 ;标签Indentation中的Tab policy选择Spaces only
    XML->XML Files->Editor 修改Line width为120

  5. 设置JavaDoc格式

    Java->Code Style->Formatter,在上述new出来的profile中,点击Edit,标签Comments里,勾选Never Join lines,取消 New Line after @param tags

  6. import static org.junit.Assert.* 不会被解开成import static org.junit.Assert.Equal

    修改Java->Code Style->Organize Import, 设置“Number of static imports needed of *”为1
    这样做是为了单元测试中不愿意写Assert.equals()/Assert.isTrue(), 又不想一个个的import所有可能用到的assert函数时有用

  7. 设置Additional actions

    Java -> Editor -> Save Actions,勾选Additional actions ,点击Configure,标签code style中勾选Use Blocks in if/while,Convert For Loop to enhanced和Use parenthese,取消Use Final Modifer where posibble

  8. 设置代码Warning

    Java-> Compiler -> Errors/Warning 在默认设置的基础上,再将下面所述项都设为Warning

    • Code Style,选Parameter Assignment和Undocument empty block
    • Potential programming problems,选Possible accidental boolean assignment、Empty Statement、Unused object alllocation、Switch case fall through、Missing synchronizied modifier on inherited method、Class override equals not hashcode
    • Name shadowing and conflicts, 全部
    • Unnessary Code, 选Value of parameter is not use和Unnecessary cast or instanceof
    • Null analysis, 选potential null access和redudant null check
      Generic Type,全部设置为Ignore
  9. XML取消掉必须有DTD的warning

    XML->XML Files->Validation,将No gammer specied改为Ignore

  10. 设置Console

    Run/Debug->Console 取消Limit Console Output

  11. 取消拼写检查

    Genernal->Editors->TextEditors->Spelling取消Enable spell checking

  12. 关闭无用窗口

    设置Eclipse右下方的窗口,将用不上的窗口关掉,如properties, database exporler, snippets等

  13. 设置Package Explorer为树形展现

    Package Explorer中->View Menu->Package presentation-Hierarchical

  14. 设置类注释模板

    Window->Preferences->java->Code Style->Code Templates->Comments->Types

    @author xiaoming(xiaoming@tomorrow.com)
    @date $(date)$(time)
    $(tags)

15.Eclipse的编辑框内显示 行号、空白、制表符、换行符:

Window->Preferences->General->Editors->text Editors->
show whitespace characters; show line numbers;

Eclipse插件

注: 最新版eclipse无需安装任何插件

  1. propedit
    Help->Install new sofeware添加站点 propedit - http://propedit.sourceforge.jp/eclipse/updates/ 勾选PropertiesEditor进行安装
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值