懒人eclipse配置

 Eclipse优化设置

  1. 设置字体大小好Window-Preferences->General->Appearance->Colors and Fonts->Basic->Text Font (Consolas/粗体/小三)(根据个人爱,自行选择)
  2. 选择喜欢的eclipse主题
  3. tab代码缩进4个空格
  4. 自定义代码注释
  5. 设置JSP编码格式
    Window->Preferences->Web->Jsp Files->Encoding->UTF-8
    设置其他文本编码格式
    Window->Preferences->General->Workspace->Text file encoding->Other->UTF-8
    设置另外文本编码格式
    Window->Preferences->General->Content Types->default encoding->UTF-8,我将Text和Word Document设为UTF-8
  6. Eclipse自动文本验证
    Window->Preferences->Validation
    保留manual(手动)部分,build下只留"classpath dependencyValidator"
  7. 优化eclipse窗口、菜单项
  8. Java > Editor > Content Assist > 禁用“Enable Auto Activation”

二 优化二

设置默认的编辑器

设置自动代码补全快捷键

设置JDK安装路径

去掉控制台打印行数限制

设置应用服务器

设置字符编码集

设置Maven

指定JVM,在-vmargs前面

三创建项目设置

1.web项目:

  1. 将Web项目的默认编译输出目录build改为WEB-INF/classes

  • 到你所配置的工作区间创建一个txt文件,并改名为:“org.eclipse.wst.web.prefs”,去掉文件后缀名 .txt
%workspace%\.metadata\.plugins\org.eclipse.core.runtime\.settings.
  • 复制以下代码到文件保存
# content directory, change the default name "WebContent" to "webroot"
 webContent=webroot

# make the default output of web project from %proj%\bin to %webroot%\WEB-INF\classes

 useSingleRootStructure=true

  • 重启你的Eclipse

2.maven项目:

    1.永久更改Maven的Dynamic Web Project版本及pom.xml默认配置

一:问题

在用eclipse创建一个maven project (webApp)时,我们一般会要进行许多麻烦的配置,比如

1.更改Java jdk版本为1.7或1.8(默认1.5)

2.补全src/main/java, src/main/resources, src/test/java, src/test/resources, 这四个目录(默认只有src/main/resources)

3.更改Dynamic Web Project的版本为3.0或3.1 (默认2.3)

4.配置pom.xml文件(默认只有junit还是3.X)

二:解决(点击pom.xml默认配置)

不建议更改display-name固定属性值
更改pom.xml


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>${groupId}</groupId>
  <artifactId>${artifactId}</artifactId>
  <packaging>war</packaging>
  <version>${version}</version>
  <name>${artifactId} Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>${artifactId}</finalName>
  </build>
</project>
<finalName>${artifactId}</finalName>

</build>

</project>
更改web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
	version="3.0">
	<display-name>Archetype Created Web Application</display-name>
  	<welcome-file-list>
  	  <welcome-file>index.html</welcome-file>
    	  <welcome-file>index.htm</welcome-file>
    	  <welcome-file>index.jsp</welcome-file>
    	  <welcome-file>default.html</welcome-file>
    	  <welcome-file>default.htm</welcome-file>
    	  <welcome-file>default.jsp</welcome-file>
  	</welcome-file-list>

</web-app>
更改index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<html>
    <body>
        <h2>Hello World!</h2>
    </body>
</html>

更改jsp页面默认模板

设置步骤如下: eclipse -- >perferences - >web ->jsp - jsp files -Editor ->templates 在这里可以设置模板。


<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">    
    <title>标题</title>        
  <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">
 </head>
 <body>
 ${cursor}
 </body>
</html>






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值