Eclipse & Spring Tool Suite commonly used configurations

Eclipse is an open source, Java-based extensible development platform. Eclipse is a Java developer commonly used development tools, although many people now turning to IDEA, but Eclipse for us still left a good memory.

Eclipse-based basis, Spring provides for the development of Spring Spring Tool Suite integrated development tool, the tool can easily generate a Spring project, such as a web project, is the most exciting project in the configuration file automatically generated for you, you no longer have to worry about the configuration file formats and various configuration files.

Official Download Spring Tool Suite are: https://spring.io/tools

This blog is based on Spring Tool Suite4 to share their development of a common configuration.

Configuration jdk

By default, MyEclipse will automatically associate the JDK environment variable configuration, multiple versions of the JDK if we installed, you can manually configure as follows: "Window" - "Preferences" - "Java" - "Installed JREs" - "Add" - "Standard VM" - select jdk installation directory.

Configuration jdk

Modify the encoding format

在菜单导航栏上Window–>Preferences 打开”首选项”对话框,左侧导航树,导航到 General–>Workspace。Windows 7和10平台默认为GBK,简体中文操作系统Windows XP、Windows 2000简体中文的缺省编码是GB18030,Linux平台默认为UTF-8.

那么在此工作空间中建立的工程编码是GBK,工程中建立的java文件也是GBK。

可以看到默认的是GBK编码格式,我们修改为UTF-8编码格式或者是你需要的编码格式

点击Apply,点击OK

Modify the encoding format

修改属性文件的编码

在MyEclipse项目文件上右键,选择Properties,在Resource选择修改编码格式

Modify the properties of the encoded file

修改新建jsp编码格式

MyEclipse中新建jsp文件的编码格式。windows -> preferences -> web -> jsp files把右边encoding的值改为ISO 10646/Unicode(UTF-8),然后应用。ok,此后新建jsp文件的内容就是UTF-8编码的了。

Modifying the new encoding format jsp

设置代码的字体类型和大小

Window -> Preferences -> General -> Appearance -> Content Assist -> Colors and Fornts,只需修改 Basic 里面的 Text Font 就可以了

Set the font type and size code

设置新建菜单项

MyEclipse默认的新建内容并不满足需求,好多内容还需要到other中去找,不过我们可以自定义新建菜单项中的内容,方法如下: Window–>Preferences–“Customize Prespective…”–“Shortcuts”–选择你需要的新建项即可。

Setting a new menu item 1

Setting a new menu item 2

安装maven插件

首先安装好maven插件,然后配置maven仓库

Installation maven plugin 1

Installation maven plugin 2

安装svn插件

在help -> Install New Software

Install svn plugin 1

Svn plugin installation 2

然后一路next,重启STS后可以找到SVN资源库

安装阿里p3c插件

插件安装

环境:JDK1.8,Eclipse4+。有同学遇到过这样的情况,安装插件重启后,发现没有对应的菜单项,从日志上也看不到相关的异常信息,最后把JDK从1.6升级到1.8解决问题。

Help -> Install New Software…

输入Update Site地址:https://p3c.alibaba.com/plugin/eclipse/update 回车,然后勾选Ali-CodeAnalysis,再一直点Next Next…按提示走下去就好。 然后就是提示重启了,安装完毕。

Ali p3c plug-in installation

注意:有同学反映插件扫描会触发很多 “JPA Java Change Event Handler (Waiting)” 的任务,这个是Eclipse的一个bug,因为插件在扫描的时候会对文件进行标记,所以触发了JPA的任务。卸载JPA插件,或者尝试升级到最新版的Eclipse。附:JPA project Change Event Handler问题解决

运行maven命令时报错

-Dmaven.multiModuleProjectDirectory system propery is not set

新建一个环境变量M2_HOME指向你的maven安装目录

M2_HOME=C:\develop\Maven\apache-maven-3.5.3

然后在Window->Preference->Java->Installed JREs->Edit

在Default VM arguments中设置

-Dmaven.multiModuleProjectDirectory=$M2_HOME

Run maven being given command

添加离线约束

有的时候,如果没有配置约束,在xml文件中就没有快捷提示,开发很不方便

DTD类型约束文件

1、window—>Preferences—>XML—>XML Catalog—>User Specified Entries窗口,点击Add按钮

2.在Add XML Catalog Entry 对话框中选择或输入以下内容:

​ Location: C:\develop\Offline-Constraint-File\mybatis-3-config.dtd

​ Key Type: URI

​ KEY: http://mybatis.org/dtd/mybatis-3-config.dtd

XSD 类型约束文件

以配置dubbo约束为例

1.window—>Preferences—>XML—>XML Catalog—>User Specified Entries窗口,点击Add按钮

2.在Add XML Catalog Entry 对话框中选择或输入以下内容:

​ Location: C:\develop\Offline-Constraint-File\ dubbo.xsd

​ Key Type: Schema Location

​ KEY: http://code.alibabatech.com/schema/dubbo/dubbo.xsd

Add constraint offline

设置在创建新类时自动生成注释

windows–>preference

Java–>Code Style–>Code Templates

code–>new Java files

${filecomment}
${package_declaration}

/**
 * Description: 
* 
 * @author JourWon
 * @date ${date} ${time}
 */
${typecomment}
${type_declaration}

Set automatically generated when creating a new class comments

给方法和重写方法生成注释

/**
 * Description: 
 * @author JourWon
 * @date ${date} ${time}
 * ${tags}
 */

And a method to override a method for generating annotations

自动生成文档注释

打开注释模板编辑窗口:Window ->Preferences->java -> Code Style -> Code Template->Comments

/**
 * Description: 
 * @author JourWon
 * @date ${date} ${time}
 * ${tags}
*/

Automatic generation of documentation comments

关闭验证(可选)

默认MyEclipse会对workspace中的项目进行验证,验证的内容包括jsp内容、xml内容,等等,验证过程很消耗内存,所以建议关闭验证功能。关闭方法如下: “Window”–“Preferences”–“Validation”–“Disable All”。

Close to verify

Spring Boot中读取属性配置文件出现中文乱码

Spring Tool Suite不需要进行此处理,只需要设置properties文件的编码为UTF-8

Chinese garbled 1 Spring Boot reads the configuration file properties appear

MyEclipse处理如下:

1.下载离线安装文件:

2.http://sourceforge.jp/projects/propedit/downloads/40156/jp.gr.java_conf.ussiy.app.propedit_5.3.3.zip/

3.安装与检验

将得到的文件直接解压,可得到这样一个文件夹

jp.gr.java_conf.ussiy.app.propedit_5.3.3 ,直接将该文件夹复制到 Eclipse目录下覆盖插件文件夹。

4.重启MyEclipse。

5.选中 *.properties 文件,右键 - Open With ,你会看到多了一个 PropertiesEditor 子菜单。

6.将PropertiesEditor设为默认的打开方式

工具栏->Window->Preferences->General->Editors->File Associations,添加一个*.properties。

下方的 Associated editors 栏里有 PropertiesEditor 项,选中,点击 Default 按钮。

双击properties文件默认就会用PropEditor打开了。

Spring Boot reads the configuration file properties appear garbled Chinese 2

Chinese garbled 3 Spring Boot reads the configuration file properties appear

设置properties文件的编码为UTF-8

Spring Boot reads the configuration file properties appear Chinese garbled 4

Spring Boot中读取属性配置文件出现中文乱码5

设置漂亮的Eclipse主题(Theme)(可选)

MyEclipse主题太丑?想设置护眼的主题?没问题

Help -> Eclipse Marketplace

设置漂亮的Eclipse主题1

然后一路next,等待ide重启

设置漂亮的Eclipse主题2

其他

修改pom.xml打开方式

Maven user interface ->open xml page

修改xml打开方式

General->editors->file associations->添加*.xml

修改xml打开方式

使用Java视图(可选)

可以根据个人喜好使用不同的视图,个人喜欢用Java视图,因为下面那一栏比较长。

使用Java视图1

使用Java视图2

修改目录显示方式为Hierachical

修改目录显示方式为Hierachical

过滤关闭的工程

过滤关闭的工程1

过滤关闭的工程2

通过工作集显示工程

通过工作集显示工程

Close MyEclipse automatic updates (optional)

Select Install / Update - Automatic Updates, uncheck Automatically find new updates and notify me the right

How to Migrate eclipse configuration information

The original working space profile:

​ metadata/.plugins/org.eclipse.core.runtime/.settings

Cover copy to the new workspace configuration files:

​ metadata/.plugins/org.eclipse.core.runtime/.settings

Note: To avoid problems, before migrating remember to do a backup configuration file in advance

Eclipse error smart tips

solution:

1. Click on the link content assist

2. Default Proposal Kinds of items [Java Proposals (Code Recommenders) √] before removing the

While checking on Java Proposals [] and [Java Proposals (Task-Focused)] two projects

Eclipse智能提示报错

Published 213 original articles · won praise 2317 · Views 150,000 +

Guess you like

Origin blog.csdn.net/ThinkWon/article/details/101025543