Eclipse 相关问题整理

2018-02-07 tool

本文整理日常使用 eclipse 过程中遇到的各类小问题以及解决方式,以备后续复查。

修改默认 jsp 模板

将 myeclipse 的默认 jsp 模板设置到 eclipse 里。

  • 打开 Prefrences -> Web -> JSP Files
  • 修改 EncodingUTF-8
  • 然后 Editor -> Templates -> New JSP File(html), 选择 Edit, 然后输入下面的内容:
<%@ page language="java" contentType="text/html; charset=${encoding}" pageEncoding="${encoding}"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
  <head>
    <base href="<%=basePath%>">
    <meta http-equiv="Content-Type" content="text/html; charset=${encoding}">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
    <title>Insert title here</title>
  </head>
  <body>
    ${cursor}
  </body>
</html>

配置启动 jdk

机器上装了多个 JDK,但是 Path 中只能指定一个,现在记录修改手动指定 EclipseJDK 路径。

在其安装路径下找到 eclipse.ini 文件,首行加入如下:

-vm
D:/jdk1.7.0_45/bin/javaw.exe

保存重启 eclipse 即可。

代码自动补全

正常情况下应该是按下快捷键 alt + / 后会弹出待选列表,结果现在是直接补全代码,不弹出选择框了。解决方法如下:

Prefrences -> General -> Keys -> 选中 Content Assist -> 修改 When -> 改为 Editing text

project 总是提示 facet 问题

  • 确认下项目属性 -> Project Facets 配置内是否报错;
  • tomcat server runtime 是否配置正确
  • 打开工程路径的 .settings 文件夹,打开 org.eclipse.wst.common.project.facet.core.xml 文件,把和问题相关的行删除。

在 eclipse 中刷新下工程基本可以解决。

逆向生成 db 实体类

在 eclipse 里可以安装 Hibernate Tools 进行逆向生成 db 实体类。点击查看详情

高分屏缩放

eclipse.ini 文件增加如下内容并重启即可。

-Dswt.enable.autoScale=true
-Dswt.autoScale=125
-Dswt.autoScale.method=nearest

Search

    Post Directory