Eclipse 使用与配置

来源:互联网 发布:2016司令部升级数据 编辑:程序博客网 时间:2024/05/29 03:15

下载时可参考,各个版本间默认安装插件比对列表

http://www.eclipse.org/downloads/compare.php


一、Eclipse一些配置

1.自动补全
Java输入任意字母时都自动补全,不用每次按ALT + /
window--> preferences->Java -> Editor -> Content  -> 
Auto activation triggers for java 输入:abcdefghijklmnopqrstuvwxyz.

xml 自动补全 
 window--> preferences-> XML - XML Files - Editor - Content Assist (搜索content)
<=:.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW


2.背景色调整为苹果绿保护眼睛

Windows 7 电脑桌面上点击右键 -> 个性化选项 -> 窗口颜色 -> 高级外观设置
“色调” 85
“饱和度” 90
“亮度” 205

windows –> preferences –> general –> editors –> Text Editors –> Appearance color options –> background color

十六进制#CCE8CF


3. 选中变量高亮显示
1) 设置高亮
windows –> preferences –> 搜索 –> Mark Occurrence 右侧勾选需要高亮的地方
或者使用快捷键Alt + Shift + 0  (Toggle Mark Occurrences) 

2) 修改同变量名背景色(Toggle Mark Occurrences)
Window->Preferences->General->Editors->Text Editors->Annotations->Occurrences
如果这种设置没看到反映,可以使用快捷键打开Alt + Shift + o

3) 修改Java匹配的两外一个括号 颜色
Window -> Preferences -> Java -> Editor -> Appearance color optionsMatching brackets highlight 

4.提高启动与运行速度,提高Eclipse内存分配大小
eclipse.ini内存设置
http://www.blogjava.net/wilesun/archive/2007/12/15/167915.html


 如何提高Eclipse的编译速度?
ant 加快eclipse下android项目编译速度
使用ant优化android项目编译速度,提高工作效率
提高Eclipse编译android工程的速度
     Window --- Preference --- Android ---- Build 照着下图修改就行



5.配置代码模板

1. 去掉每次自动生成代码都会出现的TODO Auto-generated method stub : 字符

window-->preference-->java-->code style-->code template -->code-->method body  - edit

去掉 // ${todo} Auto-generated method stub


method body
// TODO Auto-generated method stub
constructor body
// TODO Auto-generated constructor stub


2. 添加每次创建都需要添加的信息

window -> preference -> java -> code style -> code template -> Code -> Class body -> 添加每次创建都需要添加的信息,例如注释格式


* 、代码规范

1. 全局修改编码格式
windows -> Preferences -> general->Workspace -> Text file encoding -> Other -> UTF-8

2. 设置Eclipse中的tab键为4个空格的完整方法
http://my.oschina.net/xunxun10/blog/110074

3. 注释中插入时间
windows-->preference -> Java-->Code Style-->Code Templates-->code-->new Java files-->选中点编辑
${filecomment}
${package_declaration}
/**
* @author 作者姓名 E-mail: email地址
* @version 创建时间:${date} ${time}
* 类说明
*/
${typecomment}
${type_declaration}


4.自动生成UID 

Window -> Preferences -> Java -> Compiler -> Error/Warnings -> Potential programming problems ->  Serializable class without serialVersionUID
warning改成error


三、Eclipse 插件

1. 代码审查工具
findBugs  扫描程序BUG
安装: 解压edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122-15020.zip文件到eclipse/plugins 目录下之后重启。
导入:eclipse -> Preference -> Java -> FindBugs -> Filter files -> Exclude filter files

Jupiter
Jupiter Code Review Reference -- Jupiter代码审查工具使用参考 (修改版)


CheckStyle
下载地址:http://sourceforge.net/projects/eclipse-cs/
检测 : 项目上右键 -> Checkstyle -> Check Code with Checkstyle
去除 : 项目上右键 -> Checkstyle -> Clear Checkstyle violations


2. 代码UML相关工具
nWire

AmaterasUML

MaintainJ
获取运行时的流程图

Registration code
查看代码流程图

结队编程 - XPairtise


3. 其他插件
Mylyn插件(任务管理的绝好工具)
Mylyn 2.0,第 1 部分: 集成的任务管理

Beyond Compare 3(文件内容比较插件)


4. maven
*** Eclipse maven  pom.xml
SVN中的项目仅有pom.xml文件
安装Android for Maven Eclipse
File - import - maven - extra maven project 

android maven
m2e android connector
http://download.eclipse.org/technology/m2e/releases

maven-android-plugin 官网
android-maven-plugin使用

5. 自动文档  JAutodoc

6. Task视图 - 注释自动到
window-->preferences-->java-->compiler-->Task tags


四、不常用配置

1. 添加代码片段(模板)
Windows->Preferences->Java->Editor->Templates


2. 修改文件默认打开方式
window--> preferences->General->editors->Files Associations


3. 修改xml格式化的格式

 window-->preference-->XML  -->XML Files  --> Editor 中 取消掉Join lines的勾选修改注释的内容


4. 支持SVN快捷键 
windows--Customize Perspective--Command Groups Availability  -> svn 。当前环境支持svn快捷键


5. 修改File - New (Ctrl +Shift + N) 显示的内容
windows--Customize Perspective--Shortcuts (Submenus 中选择New)


五、Eclipse问题记录

1. 系统Windows 7 Eclipse 解决字体太小问题
1) 控制面板 --> 字体 --> Courier New --> 右键 --> 显示
2) eclipse preference --> Colors and Fonts --> basic --> Text Font --> edit --> Courier New -->  确定
如果字体没有变,点击一下Restore Defaults就OK了

2. 字体调小,右侧可显示Outline
eclipse preference-->General-->Appearance-->Colors and Fonts-->basic-->Text Font-->edit

3. 颜色恢复为默认方法
http://blog.csdn.net/w174504744/article/details/8672679

4. android关联不上源码  http://unmi.cc/eclipse-android-jar-attach-source-code

5. 总提示弹出Subversion Connector Discover弹出框
http://shuhucy.iteye.com/blog/1714190
在org.eclipse.ui.workbench.prefs文件中搜索"SVNLightweightDecorator"将后面的true值该为false即可 


6. Eclipse 启动未响应
问题原因:上一次为正常关闭Eclipse
Workspace\.metadata\.log 查看异常信息,看读取哪一个项目出现问题
我的解决办法:
Workspace\.metadata\.plugins\org.eclipse.core.resources\.projects\ 出问题项目文件夹删除
阅读资料:
经验2;eclipse 启动后,处于无响应状态解决方案(判断出是.metadata目录问题)
http://blog.csdn.net/lala_21/article/details/2570715

7. Eclise svn插件问题
7.1 Some of selected resources were not committed.
Some of selected resources were not committed.
svn: E175002: Commit failed (details follow):
svn: E175002: Commit failed (details follow):
svn: E175002: MKACTIVITY of '/svn/!svn/act/bed9cd8a-3a01-0010-b186-6f076972ec7b': 405 Method Not Allowed
svn: E175002: MKACTIVITY request failed on '/svn/!svn/act/bed9cd8a-3a01-0010-b186-6f076972ec7b'

http://www.iunbug.com/archives/2012/08/03/394.html
在eclipse.app–>右键–>显示内容包–>Content/MacOS/eclipse.ini–>编辑在最后加-Dsvnkit.http.sslProtocols=SSLv3

7.2 安装eclipse 插件遇到问题
warning you are installing software that contains unsigned content. the authenticity or validity of this software cannot be established .
Eclipse SVN 需求javaHL
再说说如何安装javaHL吧(以Ubuntu操作系统为例):
       1、在终端运行:sudo apt-get install libsvn-java
       2、检查/usr/lib/jni目录是否存在,如果不存在,说明javaHL没有安装成功
最后需要修改eclipse配置,使javaHL起作用:
       1、在eclipse目录下的eclipse.ini添加: -Djava.library.path=/usr/lib/jni
       2、确认是否已经安装subclipse插件,如果没有,请自行安装,可以直接在eclipse中更新,也可以下载subclipse的包,手动安装插件
       3、重启eclipse,一切搞定!!! 
 do you want to continue with the installation

8. 启动弹出以下异常

A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No java virtual machine was found after searching the following locations: javaw.exe javaw.exe in your current PATH
没有设置JDK环境变量  《Windows JDK配置环境变量》

9.总是到Launch workbench就卡死或者直接关闭,下次仅删除一个试试

删除以下一个文件夹 :.metadata\.plugins\org.eclipse.e4.workbench

10. 异常
an out of memory error has occurred.Consult the "Running Eclipse" section of the read me file for information on preventing this kind of error in the future.
解决:
eclipse.ini中以下两个参数的值相同即可
-XX:PermSize=512M
-XX:MaxPermSize=512M



六、参考资料:

让开发自动化: 用 Eclipse 插件提高代码质量
http://www.ibm.com/developerworks/cn/java/j-ap01117/


25个让Java程序员更高效的Eclipse插件
http://dev.yesky.com/469/31067469.shtml


2014-04-04 更新设置


原创粉丝点击