# Eclipse
# Flag
- https://gitlab.eclipse.org (opens new window)
- https://github.com/eclipse/eclipse (opens new window)
- https://github.com/eclipse-platform (opens new window)
- https://github.com/eclipse-jdt (opens new window)
- https://github.com/eclipse-cdt (opens new window)
- https://github.com/eclipse-pde (opens new window)
- https://github.com/eclipse-m2e (opens new window)
- https://github.com/eclipse-tycho (opens new window)
- https://github.com/eclipse-windowbuilder (opens new window)
- https://github.com/eclipse-wildwebdeveloper (opens new window)
- https://github.com/eclipse-linuxtools (opens new window)
- https://github.com/eclipse-oomph (opens new window)
- https://github.com/eclipse-cbi (opens new window)
- https://github.com/eclipse-simrel (opens new window)
- https://www.eclipse.org/ide (opens new window)
- https://eclipseide.org (opens new window)
- https://www.eclipse.org/downloads/packages (opens new window)
- 可视化 https://www.jgrasp.org (opens new window)
- 设置 https://github.com/vorburger/opendaylight-eclipse-setup (opens new window)
- Spring Toolshttps://github.com/spring-projects/sts4 (opens new window)
- 单行注释自动靠左 (opens new window)
- Eclipse的Debug各种视图介绍 (opens new window)
- STS(eclipse)中文注释错位、缩进、被放大BUG解决 (opens new window)
- Eclipse的设置、调优、使用(解决启动卡顿等问题) (opens new window)
- 多模块打包后,扫描不到@controller和@service (opens new window)
创建
Dynamic Web Project项目结构静态资源目录为:WebContent/WebRoot,idea创建的为web导入的项目没有正确自动识别:在项目上右键选择Properties然后检查Project Facets和Project Natures
快捷生成调用实例set方法
- 进入实例类,打开
Type Hierarchy视图并在视图中选中所有set方法复制,快捷键F4 - 使用反射获取方法生成 (opens new window)
xml文件头部文件报错
%USERPROFILE%\.lemminx\cache\头部文件的链接地址路径
示例:链接地址为
http://mybatis.org/dtd/mybatis-3-config.dtd文件路径为%USERPROFILE%\.lemminx\cache\http\mybatis.org\dtd\mybatis-3-config.dtd
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部署的当前项目目录
# 右键菜单
Window->Perspective->Customize PerspectiveShortcuts新建选项
# 安装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
# 代码格式化
- 顶部菜单 ->
Source->Clean Up针对代码的内容进行整理,比如去除无用代码或者引用包。 - 顶部菜单 ->
Source->Format对代码的格式进行整理,比如设置了Table为4个空格,那么将会转换。 - 顶部菜单 ->
Source->Organize Imports去除单个类中无用的引用包信息Ctrl + Shift + O
垂直标尺
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->Web->Client-side JavaScript->Code Style->Formatter->New->Edit- ->
Line Wrapping行宽Maximum Line widthSet line width for preview window设置预览窗口的线宽
- ->
CommentsMaximum line width for comments
- ->
JSP|HTML|CSS 格式化
Window->Preferences->Web->HTML Files/CSS Files->EditorLine width行宽Inline Elements选中所有 ->RemoveIndent using spaces缩进使用空格Indentation size缩进使用多少个字符
XML
Window->Preferences->Web->XML->XML Files->EditorFormatting->Line width行宽
# 设置编码格式
- 设置工作空间编码
Window->Preferences->General->Workspace->Text file encoding->Other选择UTF-8->Apply - 设置编辑器编码
Window->Preferences->General->Editors->Text Editors->Spelling->Encoding位置的Other选择UTF-8->Apply - 设置文档编码
Window->Preferences->General->Content Types- ->
Text->Default encoding填入UTF-8(填入编码后一定要点击Update) - -> 展开
Text- -> 选中
Java Properties File->Default encoding填入UTF-8设置Properties编码 - -> 选中
Spring Properties File->Default encoding填入UTF-8 - -> 选中
JSP->Default encoding填入UTF-8设置JSP编码 - -> 展开
JSP- ->
JSP Fragment->Default encoding填入UTF-8 - ->
JSP Tag Definition->Default encoding填入UTF-8 - -> 展开
JSP Tag Definition->XML JSP Tag Definition->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 - 配置全局生效,在Eclipse的启动配置文件
eclipse.ini中添加-Dfile.encoding=UTF-8 - 设置Tomcats的编码
Run>Run Configurations...-> 选择Java Application下的应用 ->Arguments->VM arguments添加-Dfile.encoding=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 onlyWindow->Preferences->Web->CSS Files、HTML Files、JSP Files->Editorlndent using spaces选中lndentation size空格数
# 自动提示
Window->Preferences->Java->Editor->Content AssistAuto ActivationAuto activation delay(ms)提示的延迟时间Auto Activation triggers for java填入._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ(,'"@
Advanced- 勾选
Java Proposals (Task-Focused) - 勾选
Template Proposals
- 勾选
- 解决输入
=或;变量自动补全问题:勾选Disable insertion triggers except 'Enter'(按Enter键才自动补全)
- XML自动补全
Windows->preferance->XML->XML Files->Editor->Content AssistAuto Activation下面的Prompt when these characters are inserted填入<=:.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ(注意后面有一个空格)
- 按
@不提示注解:Window->Preferences->Java->Editor->Content AssistAdvanced下把java Proposals勾上Enable non-blocking completion(does not affect open editors)启用非阻塞完成(不影响打开的编辑器)
- 高亮显示
Window->Preferences->Java->Editor->Mark OccurencesMark occurrences of the selected element in the current file.高亮显示选中的相同变量
# 清除缓存
- 顶部菜单 ->
Project->Clean根据项目.classpath文件,清除编译信息,重新部署到Java Build Path下的Default output folder中。 Servers->Clean是指原先编译到tomcat服务器上的程序,先清除掉,然后再重新编译。Servers->Clean Tomcat Work Directory...将已发布项目中存放jsp转译后的class文件的work目录删除
# 自动刷新
Windows->Preference->GeneralWorkspaceBuildSave automatically before manual build在手动构建之前自动保存Build automatically(同Project菜单下的按钮) 自动编译
Refresh using native hooks or polling自动刷新文件Refresh on access访问时刷新Always close unrelated projects without prompt总是在不提示的情况下关闭不相关项目Workspace save interval (in minutes)工作区保存时间间隔(分钟)
Startup and ShutdownRefresh workspace on startup启动时刷新工作空间
# 查看类图及继承关系
- 选中类,右键然后有以下选项
Open DeclarationF3 Open Type HierarchyF4 打开类层次结构查看窗口,显示包括它的父类和子类Show the Subtype Hierarchy只查看子类Show the Supertype Hierarchy只查看父类
Open Call HierarchyCtrl +Alt +H Show in BreadcrumbAlt +Shift +B 面包屑导航Quick OutlineCtrl +O Quick Type HierarchyCtrl +T 打开类层次结构查看弹窗,显示包括它的父类和子类
# 项目显示结构
Windows->Show View->Other-> 搜索Package ExploerWindows->Show View->Other-> 搜索Tasks查看待办任务
Window->Preferences->Java->Compiler->Task tags定义任务标签// TODO表示尚未完成的待办事项。// XXX表示被注释的代码虽然实现了功能,但是实现方案有待商榷,希望将来能改进。// FIXME表示被注释的代码需要被修正。
# 显示内存
在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->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
# 注释模板
Help->Help Contents-> 搜索Java Editor Template VariablesWindow->Preference->Java->Code Style->Code Templates- 展开
Comments-> 点击选中子项(files、Types) ->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)注释标签
/** ${field} */
- 构造函数(Constructors)标签
/**
* @Title ${enclosing_type}
* ${tags}
* @author bajins.com
* @date ${date} ${time}
*/
- 方法(Methods)标签
/**
*
* ${tags} ${return_type}
* @author bajins.com
* @date ${date} ${time}
*/
- 覆盖方法(Overriding Methods)标签
/**
* @Title ${enclosing_method}
* @Description
* ${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}
* @Description 获取字段“${bare_field_name}”的值
* @return ${field_type}
* @author bajins.com
* @date ${date} ${time}
*/
- setter方法标签
/**
* @Title ${enclosing_method}
* @Description 设置字段“${bare_field_name}”的值
* @param ${param}
* @author bajins.com
* @date ${date} ${time}
*/
# 命令执行
eclipsec应用程序
org.eclipse.jdt.core.JavaCodeFormatter格式化 Java 代码-config
org.eclipse.jdt.core.JavaCompiler编译 Java 代码-sourcepath-classpath
org.eclipse.equinox.p2.director安装、更新或卸载 Eclipse 插件-repository-installIU--
org.eclipse.ant.core.antRunner运行 Apache Ant 构建脚本-buildfile
org.eclipse.ui.ide.workbench启动 Eclipse IDE 工作台org.eclipse.jdt.apt.core.aptBuild运行 Java 注解处理器(Annotation Processing Tool)-sourcepath-classpath
org.eclipse.jdt.core.JavaIndexer索引 Java 项目-sourcepath
org.eclipse.jdt.core.JavaModelManager管理 Java 模型-sourcepath
org.eclipse.update.core.standaloneUpdate更新 Eclipse 安装-command install-featureId org.eclipse.platform
org.eclipse.core.launcher.Main启动 Eclipse 主应用程序
启动
eclipse -consoleLog -nosplash -data <workspace>
格式化代码
eclipsec -data <workspace> -application org.eclipse.jdt.core.JavaCodeFormatter [ OPTIONS: -help、-quiet、-verbose ] -config <configFile> <files>Window->Preferences->Java->Code Style->Formatter->Export All导出格式化代码的配置XML文件
编译构建
eclipsec -nosplash -data <workspace> -application org.eclipse.ant.core.antRunner -buildfile <buildFile>
<!-- build xml 格式化代码,使用ant format命令 -->
<project name="FormatCode" default="format" basedir=".">
<property name="eclipse.home" value="eclipse文件夹" />
<property name="src.dir" value="src" />
<target name="format">
<java classname="org.eclipse.jdt.core.formatter.CodeFormatter" fork="true">
<classpath>
<pathelement location="${eclipse.home}/plugins/org.eclipse.jdt.core_*.jar"/>
</classpath>
<arg value="-process"/>
<arg value="${src.dir}"/>
</java>
</target>
</project>
# 插件安装使用
一般插件都有
plugins和features两个文件夹,复制到eclipse安装目录即可
-vmargs -DproxySet=true -DproxyHost=aProxyAddress -DproxyPort=aProxyPort启动代理参数Eclipse Web Developer Tools
- https://marketplace.eclipse.org/metrics/successful_installs/last30days (opens new window)
- https://github.com/de-jcup (opens new window)
- https://github.com/eclipse-mylyn (opens new window)
- SVN https://www.eclipse.org/subversive (opens new window)
- https://github.com/subclipse (opens new window)
- 代码覆盖率 https://github.com/eclipse/eclemma (opens new window)
- 数据库 https://dbeaver.io/download (opens new window)
- 折叠代码块 https://github.com/stefaneidelloth/EclipseFolding (opens new window)
- https://sourceforge.net/projects/coffeeby1 (opens new window)
- user-defined-code-folding-regions-in-eclipse (opens new window)
- https://github.com/sky1983/EclipseFolding (opens new window)
将插件放在
eclipse\dropins,重启eclipse,Window->Preferences->Java->Editor->Folding在Select folding to use项选择:Coffee Bytes Java Folding - https://github.com/GrowThinky/AnnotationSupportEclipsePlugin (opens new window)
- https://github.com/qiangitchen/tlv8ide (opens new window)
- https://github.com/gildur/SimplePropertiesEditor (opens new window)
- https://github.com/FeatureIDE/FeatureIDE (opens new window)
- https://github.com/nodj/AutoDeriv (opens new window)
- https://www.esito.no/en/promo-g9 (opens new window)
- 文本编辑器 https://github.com/fabioz/LiClipseText (opens new window)
- GUI设计 https://github.com/eclipse/windowbuilder (opens new window)
- 开发风格 https://www.genuitec.com/products/devstyle (opens new window)
- http://kurucz-grafika.de/fatjar (opens new window)
- https://sourceforge.net/projects/eclipsetidy (opens new window)
- https://sourceforge.net/projects/eclipse-tools (opens new window)
- https://github.com/sebthom/findview-eclipse-plugin (opens new window)
- Prettier https://github.com/TheGreatGooo/EclipsePrettierPlugin (opens new window)
- https://github.com/AObuchow/Eclipse-Spectrum-Theme (opens new window)
反编译Decompiler
Window->Preferences->General->Editors->File Associations- 在
File types选中*.class或*.class without source - 在
Associated editors选中Class Decompiler Viewer点击Default
- 在
Window->Preferences->Java->DecompilerEscape unicode characters转义unicode字符Realign line numbers重新对齐行号Show original line numbers显示原始行号Show metadata显示元数据
- https://github.com/ecd-plugin/ecd (opens new window)
- 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)
- https://sourceforge.net/projects/drgarbagetools (opens new window)
- https://github.com/helospark/import-jar-as-project (opens new window)
- 测试 https://github.com/ot4i/perf-harness (opens new window)
Cloud Toolkit
帮助开发者更高效地开发、测试、诊断并部署应用。通过插件,可以将本地应用一键部署到任意服务器