版本说明
IntelliJ IDEA 2017.1
JDK 1.8.0
tomcat apache-tomcat-8.5.16
其他较低版本亦可
Idea与eclipse的区别
最重要的一点区别就是IntelliJ IDEA 提倡一个工作空间 (在 IDEA 中叫 project)就写一个项目,这样我们的工作空间就跟着项目走,而eclipse 中把项目和工作空间分开,比较难于管理。所以我们在网上还会看到有人问在 eclipse 工作空间中已经存在的项目如何导入到工作空间中去,有的时候会比较迷茫。
1,创建Project:依次点击File–>New->Project;

2.配置SDK,勾选Web Application

3.填写项目名称,选择项目路径,点击Finish

4.右击WEB-INF文件夹,新建classes和lib文件夹


5.File -> Project Structure (Ctrl + Shift + Alt + S),进入Project Structure窗口

6.点击Modules -> Paths,勾选"Use module compile output path",将"Output path"和"Test Output path"都改为之前创建的classes目录

7.点击Modules -> Dependencies,点击"+"->"Jars or directories"

8.选择之前创建的lib目录 ->"jar directory"-> OK -> Apply -> OK


配置Tomcat
1、Run -> Edit Configurations,进入"Run Configurations"窗口

2.点击"+"-> Tomcat Server -> Local,创建一个新的Tomcat容器

3.在"Name"处输入新的服务名,点击"Application server"后面的"Configure...",弹出Tomcat Server窗口,选择本地安装的Tomcat目录 -> OK

5.在"Run Configurations"窗口的"Server"选项板中,取消勾选"After launch",设置"HTTP port"和"JMX port",点击 Apply -> OK, 至此Tomcat配置完成。

在Tomcat中部署并运行项目
1.Run -> Edit Configurations,进入"Run Configurations"窗口,选择之前配置好的Tomcat,点击"Deployment"选项卡,点击"+"->"Artifact"-> 选择创建的web项目

2.修改"Application context"-> Apply -> OK

3.运行Tomcat,在浏览器中查看运行结果


网友评论