第一步:Eclipse中进行以下菜单设置:java
Window - Preferences - General - Content Types,右侧Text - java Properites File 在Default encoding中输入UTF-8,点击Update。spring
若是自定义配置文件未更新编码格式,可在属性中手动设置为utf-8。app
第二步:安装PropertiesEditor。在Help - Eclipse Marketplace 中查找、安装PropertiesEditor。经过PropertiesEditor编辑的配置文件,不会再出现乱码。
(方法一)
一、首先,在eclipse中点击“help”-"Install New Software"。
2,、点击右侧的“Add”按钮。
三、输入
Name:properties。
Location:http://propedit.sourceforge.jp/eclipse/updates/
而后点击OK。
四、稍等两分钟,就会出现插件列表,选择PropertiesEditor,而后Next.
五、继续Next。
六、点击“I accept ……”,而后Finish.。
七、安装完成后点击“Restart Now”重启eclipse。
八、此时在properties文件上点右键,点击“Open With"-"PropertiesEditor",打开文件,如今就能够直接输入中文了eclipse
方法二:
1.下载离线安装文件:http://sourceforge.jp/projects/propedit/downloads/40156/jp.gr.java_conf.ussiy.app.propedit_5.3.3.zip/
2.安装与检验
将获得的文件直接解压,可获得这样一个文件夹 jp.gr.java_conf.ussiy.app.propedit_5.3.3 ,直接将该文件夹复制到 Eclipse目录下覆盖插件文件夹。ide
3.重启Eclipse。
4.选中 .properties 文件,右键 - Open With ,你会看到多了一个 PropertiesEditor 子菜单。
5.将PropertiesEditor设为默认的打开方式
工具栏->Window->Preferences->General->Editors->File Associations,添加一个.properties。
下方的 Associated editors 栏里有 PropertiesEditor 项,选中,点击 Default 按钮。
双击properties文件默认就会用PropEditor打开了。工具
另外,读取配置文件时,自定义配置文件类中@PropertySource注解中也可指明编码格式。以下:编码
@PropertySource(value= {"classpath:config.properties"},encoding="UTF-8")
固然,若是你安装了PropertiesEditor就不必这么使用注解了。spa
最后一样重要的是eclipse 版本是
只要设置第一步就能够了插件