安装包
安装jdk :D:Program FilesJavajdk1.7.0_17
下载tomcat:E:apache-tomcat-6.0.36
下载maven:E:apache-maven-3.1.0
环境变量
配置tomcat环境变量:
CATALINA_BASE E:apache-tomcat-6.0.36
CATALINA_HOME E:apache-tomcat-6.0.36
配置maven环境变量
M2_HOME E:apache-maven-3.1.0
M2 %M2_HOME%in
配置jdk环境变量
JAVA_HOME D:Program FilesJavajdk1.7.0_17
CLASSPATH .;%JAVA_HOME%libdt.jar;%JAVA_HOME%lib ools.jar;
path %SystemRoot%system32;%SystemRoot%;%SystemRoot%System32Wbem;%SYSTEMROOT%System32WindowsPowerShellv1.0;D:Program FilesTortoiseSVNin;%JAVA_HOME%in;%JAVA_HOME%jrein;%M2%;
配置maven开源中国源
http://maven.oschina.net/help.html
tomcat配置站点
删除confCatalina下所有文件conf新建Catalinalocalhost est.xml站点
<Context path="/test" docBase="E: c estwww" debug="0" privileged="true"> </Context>
删除webapps下所有目录
idea集成jdk,tomcat,maven开发环境
新建工程:javaee web module
配置maven
配置jdk
配置工程artfacts:war exploded 设置output directory:E: c estwww
配置tomcat:deployment:war exploded
为工程添加maven模块add framework support maven
建立servlet测试接口
新建servlet类文件com.Test
package com; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; public class Test extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.println("helloworld"); } }
maven处理jar依赖pom.xml
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet</artifactId> <version>3.0.0.v201103241009</version> </dependency>
idea启动tomcat 显示
Server startup in 79 ms
Connected to server
Artifact web:war exploded: Artifact is deployed successfully
访问测试:http://localhost:8080/Test
helloworld