安装包
安装jdk :D:\Program Files\Java\jdk1.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%\bin
配置jdk环境变量
JAVA_HOME D:\Program Files\Java\jdk1.7.0_17
CLASSPATH .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
path %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;D:\Program Files\TortoiseSVN\bin;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;%M2%;
配置maven开源中国源
http://maven.oschina.net/help.html
tomcat配置站点
删除conf\Catalina下所有文件conf新建\Catalina\localhost\test.xml站点
<Context path="/test" docBase="E:\tc\test\www" debug="0" privileged="true"> </Context>
删除webapps下所有目录
idea集成jdk,tomcat,maven开发环境
新建工程:javaee web module
配置maven
配置jdk
配置工程artfacts:war exploded 设置output directory:E:\tc\test\www
配置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