# Eclipse
# Flag
- https://www.eclipse.org/ide (opens new window)
- http://www.eclipse.org/downloads/packages (opens new window)
- 单行注释自动靠左 (opens new window)
- Eclipse的Debug各种视图介绍 (opens new window)
- https://github.com/eclipse/wildwebdeveloper (opens new window)
- Mars之后版本不再集成支持JavaScript需要安装插件,参考Tern Eclipse IDE (opens new window)
Windows->Preference->General->Workspace-->BuildSave automatically before manual build在手动构建之前自动保存Build automatically(同Project菜单下的按钮) 自动编译
Clean Up、Format、Clean
- 顶部菜单 ->
Source->Clean Up针对代码的内容进行整理,比如去除无用代码或者引用包。 - 顶部菜单 ->
Source->Organize Imports去除单个类中无用的引用包信息Ctrl + Shift + O - 顶部菜单 ->
Source->Format对代码的格式进行整理,比如设置了Table为4个空格,那么将会转换。 - 顶部菜单 ->
Project->Clean根据当前项目情况更新.classpath文件的内容,强制检查已安装插件,清除编译信息,重新部署项目。 Servers->Clean是指原先编译到tomcat服务器上的程序,先清除掉,然后再重新编译。Servers->Clean Tomcat Work Directory...将已发布项目中存放jsp转译后的class文件的work目录删除
项目显示结构
Windows->Show View->Other-> 搜索Package Exploer
WebStorm保存后跳过Eclipse自动同步到Tomcat
File->Settings->Build, Execution, Deployment->Deployment(或顶部菜单Tools->Deployment->Configuration)- 配置一个应用:右侧点击
+号 -> 点击Local or mounted floder-> 输入自定义名称- 右侧
Connection页签Floder选择Eclipse配置的Tomcat部署的当前项目路径
- 右侧
Mappings页签Local path需要部署的文件路径(相对项目根目录)Deployment path把Local path部署到指定路径(相对Floder的路径)一般为\
- 右侧
- 点击顶部菜单
Tools->Deployment-> 选择Automatic Upload(always)自动构建
其实原理很简单:就是在保存源码文件的同时,实时编译构建同步的时候跳过Eclipse,直接同步到Tomcat部署的当前项目目录
# 安装Java EE开发插件
默认没有
Dynamic Web Project
Help->Install New Software->Work with选择All available Sites-> 勾选Web,XML,Java EE and OSGi Enterprise Development->Next->I accept the terms of the licence agreement
# 字体大小和背景色
- 调节控制台字体大小
Window->Preferences->General->Appearance->Colors and Fonts->Basic->Text Font->Edit - 调节主窗口字体大小
Window->Preferences->General->Appearance->Colors and Fonts->Java->Java Editor Text Font->Edit - 设置眼睛保护色
Window->Prefences->General->Editors->Text Editors->Appearance color optins
# 代码格式化
垂直标尺
Window->Preferences->General->Editors->Text Editors->Show Print MarginPrint margin column行宽Allow editors to override the margin column
Java 格式化
Window->Preferences->Java->Code Style->Formatter->New->Edit- ->
Line WrappingMaximum Line width控制每行的最大字符数Set line width for preview window设置预览窗口的线宽- ->
Wrapping settings->Binary expressions->Line wrapping policy->Wrap all elements,every elements on a new line将所有元素换行,每个元素都换行 - ->
Function Calls->Qualified invocations->Wrap all elements,every elements on a new line连续调用不换行 Never join already wrapped lines不格式化已换行的
- ->
Comments注释Maximum line width for comments注释的最大行宽Count width from comment's starting position从注释的开始位置计算宽度
Enable Javadoc comment formatting启用Javadoc注释格式Enable block comment formatting启用块注释格式(每一行以*开头)Enable line comment formatting启用行注释格式Format line comments on first column格式化代码与注释符之间的间距
Enable header comment formatting启用标题注释格式Preserve whitespace between code and line comments保留代码和行注释之间的空格Never indent line comments on first column切勿在第一列缩进行注释Never indent block comments on first column切勿在第一列缩进块注释Never join lines从不连接线
- ->
JavaScript 格式化
Window->Preferences->JavaScript->Code Style->Formatter->New->Edit- ->
Line WrappingMaximum Line widthSet line width for preview window
- ->
CommentsMaximum line width for comments
- ->
JSP|HTML|CSS 格式化
Window->Preferences->Web->HTML Files/CSS Files->EditorLine widthInline Elements选中所有 ->RemoveIndent using spaces缩进使用空格Indentation size缩进使用多少个字符
# 自动提示
Window->Preferences->Java->Editor->Content Assist->Auto Activation下的Auto Activation triggers for java填入._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ- 解决输入
=或;变量自动补全问题Window->Preference->Java->Editor->Content Assist-> 勾选Disable insertion triggers except 'Enter'(按Enter键才自动补全) - XML自动补全
Windows->preferance->XML->XML Files->Editor->Content Assist->Auto Activation下面的Prompt when these characters are inserted填入<=:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ(注意后面有一个空格)
- 解决按下
@不提示注解:Window->Preferences->Java->Editor->Content Assist->Advanced下把java Proposals勾上
# 显示内存
在eclipse中打开heap状态
Windows->Preference->General–> 勾选show heap status
# 解决卡死现象
Eclipse中jsp、js文件编辑时,卡死现象解决
- 取消验证
Windows->Preference–>validation-> 点击Disable All然后勾选classpath dependency ValidatorAllow projects to override these preference settings允许项目覆盖这些首选项设置Suspend all validators暂停所有验证器Save all modified resources automatically prior to validating验证之前自动保存所有修改的资源Show a confirmation dialog when performing manual validations执行手动验证时显示确认对话框
- 关闭拼写检查
Windows->Preference->General–>editors->Text Editors->spelling - 选中项目点击右键 ->
Properties->Builders在右边取消勾选除Java Builder以外的其他选项
# 清除workspace历史记录
Windows->Preference->General–>Startup and Shuodown->Prompt for workspace on startup/Workspaces- 编辑eclipse下的
/configuration/.settings/org.eclipse.ui.ide.prefs->RECENT_WORKSPACES删除不需要的目录,以\n分隔
# 调整运行内存
- 在eclipse的安装目录下编辑
eclipse.ini文件
# JDK8以下
-Xms128M -Xmx512M -XX:PermSize=64M -XX:MaxPermSize=128M
# JDK8
-Xms128M -Xmx512M -XX:MetaspaceSize=512m -XX:MaxMetaspaceSize=1024m
-Xms128mJVM初始分配的堆内存-Xmx512mJVM最大允许分配的堆内存,按需分配-XX:PermSize=64MJVM初始分配的非堆内存,JDK8之前-XX:MaxPermSize=128MJVM最大允许分配的非堆内存,按需分配,JDK8之前-XX:MetaspaceSize=512m元数据,JDK8-XX:MaxMetaspaceSize=1024m最大元数据,JDK8
设置JDK参数
Windows->Preference->Java–>Installed JREs-> 选中使用的JDK ->Edit->Default VM arguments
设置Tomcat参数
Run->Run Configurations-> 选中已添加的Tomcat ->Arguments-> 在VM arguments中换行添加
# 设置编码格式
- 设置工作空间编码
Window->Preferences->General->Workspace->Text file encoding->Other选择UTF-8 - 设置文档编码
Window->Preferences->General->Content Type->Text->Default encoding填入UTF-8 - 设置Web编码
Window->Preferences->Web->CSS Files、HTML Files、JSP Files->Encoding选择ISO 10646/Unicode(UTF-8) - 设置项目的文档编码:选中项目右键 ->
Properties->Resource->Other选择UTF-8
# 设置Tab为空格
Window->Preferences->General->Editors->Text Editors-> 勾选Insert spaces for tabsRemove multiple spaces on backspace/delete删除退格键/删除多个空格
Window->Preference->Java->Code Style->Formatter->Edit->Indentation->Tab policy选择Spaces only
# 快捷键设置
Window->Preference->General->Keys- 设置复制一行 搜索
Ctrl+Alt+Down或者Copy Lines即可修改
# 自动导包
Window->Preferences->Java->Editor->Save Actions-> 勾选Preform the selected actions on saveFormat edited lines自动格式化修改的行Organize impots自动优化管理导入的包
# 右键new选项
Window->Perspective->Customize Perspective...->Shortcuts界面 ->Submenus列中选中Java
# SUN内部包不存在
sun.misc(sun公司的内部方法,不属于JDK标准库范畴)包下的BASE64Encoder及BASE64Decoder来进行的
- 项目右键 ->
Build Path->Configure Build Path->Java Build Path->Libraries-> 展开JRE System Libraries-> 选中Access rules-> 点击Edit-> 弹窗点击Add->Resolution选择Accessible->Rule Pattern输入**-> 点击OK
# 注释模板
Window->Preference->Java->Code Style->Code Template-> 展开Comments-> 点击需要设置的类型 ->Pattern填入注释模板 -> 勾选Automatically add comments for new methods and types- 注释的使用:输入
/**然后回车自动出来
- 创建新文件(New Java files)注释标签(在文件第一行)
- 类型(Types)注释标签(在主体声明上)
/**
* @Title: ${file_name}
* @Package ${package_name}
* @Description:
* @author: bajins.com
* @date: ${date} ${time}
* @version V1.0
* @Copyright: ${year} bajins.com Inc. All rights reserved.
*/
- 字段(Fields)注释标签
/**
* @Fields ${field} :
* @author: bajins.com
* @date: ${date} ${time}
*/
- 构造函数(Constructors)标签
/**
* @Title: ${enclosing_type}
* ${tags}
* @author: bajins.com
* @date: ${date} ${time}
*/
- 方法(Methods)标签
/**
*
* ${tags} ${return_type}
* @author: bajins.com
* @date: ${date} ${time}
*/
- 覆盖方法(Overriding Methods)标签
/**
* <p>Title: ${enclosing_method}</p>
* <p>Description: </p>
* ${tags}
* ${see_to_overridden}
* @author: bajins.com
* @date: ${date} ${time}
*/
- 代表方法(Delegate Methods)标签
/**
* ${tags}
* ${see_to_target}
* @author: bajins.com
* @date: ${date} ${time}
*/
- getter方法标签
/**
* @Title: ${enclosing_method} <BR>
* @Description: please write your description <BR>
* @return: ${field_type} <BR>
* @author: bajins.com
* @date: ${date} ${time}
*/
- setter方法标签
/**
* @Title: ${enclosing_method} <BR>
* @Description: please write your description <BR>
* @return: ${field_type} <BR>
* @author: bajins.com
* @date: ${date} ${time}
*/
# 插件
-vmargs -DproxySet=true -DproxyHost=aProxyAddress -DproxyPort=aProxyPort启动代理参数
- SVN https://github.com/subclipse (opens new window)
- 反编译Decompiler https://github.com/ecd-plugin/ecd (opens new window)
Window->Preferences->General->Editors->File Associations-> 右侧在File types中选中*.class without source在Associated editors中选中Class Decompiler Viewer点击Default
- https://github.com/iloveeclipse/plugins/wiki (opens new window)
- https://github.com/java-decompiler/jd-eclipse (opens new window)
- https://github.com/cnfree/Eclipse-Class-Decompiler (opens new window)
- https://github.com/helospark/import-jar-as-project (opens new window)
Cloud Toolkit
帮助开发者更高效地开发、测试、诊断并部署应用。通过插件,可以将本地应用一键部署到任意服务器