首页 技术 正文
技术 2022年11月15日
0 收藏 732 点赞 3,979 浏览 1251 个字

安装工具

1、JDK7+

2、IntelliJ Idea 工具(下载安装后,网上找注册码破解即可)

3、tomcat7+ 解压缩版

明确两个概念:

1、Project:类似于eclipse的workspace概念

2、Module:类似于eclipse的工程项目概念

[Intellij] 在IntelliJ IDEA 中创建运行web项目

当然,实际开发中最好是一个Project对应一个module。

【1、创建一个项目】

入口

首次:

[Intellij] 在IntelliJ IDEA 中创建运行web项目

工作界面:

[Intellij] 在IntelliJ IDEA 中创建运行web项目

注意选择红框部分

[Intellij] 在IntelliJ IDEA 中创建运行web项目

一路next。

新建文件夹:F:\IntelliJ_IDEA_Project\DemoProject 作为示例project的存放路径

[Intellij] 在IntelliJ IDEA 中创建运行web项目

点击finish,完成project创建。

[Intellij] 在IntelliJ IDEA 中创建运行web项目

[Intellij] 在IntelliJ IDEA 中创建运行web项目

【2、创建一个Module】

鼠标点中项目名称DemoProject-> 右键选择New,选择Module

[Intellij] 在IntelliJ IDEA 中创建运行web项目

勾选“Web Application” -> 确认已勾选“Create web.xml” -> Next

[Intellij] 在IntelliJ IDEA 中创建运行web项目

输入Module名字和存储路径,点击finish

[Intellij] 在IntelliJ IDEA 中创建运行web项目

生成文件:

[Intellij] 在IntelliJ IDEA 中创建运行web项目

工作台:

[Intellij] 在IntelliJ IDEA 中创建运行web项目

【3、设置产出和依赖目录

右键文件夹WE-INF,在web/WEB-INF下创建两个文件夹:classes和lib,并设置产出路径

[Intellij] 在IntelliJ IDEA 中创建运行web项目

classes用来存放编译后输出的class文件,lib用于存放第三方jar包。

[Intellij] 在IntelliJ IDEA 中创建运行web项目

File -> Project Structure (快捷键:Ctrl + Shift + Alt + S) -> 选择Module :

选择 Paths -> 选择”Use module compile output path” -> 将Output path和Test output path都选择刚刚创建的classes文件夹。

[Intellij] 在IntelliJ IDEA 中创建运行web项目

接着选择Dependencies ->  将Module SDK选择为1.7 -> 点击右边的“+”号  -> 选择1 “Jars or Directories” [Intellij] 在IntelliJ IDEA 中创建运行web项目

[Intellij] 在IntelliJ IDEA 中创建运行web项目

[Intellij] 在IntelliJ IDEA 中创建运行web项目

勾选

[Intellij] 在IntelliJ IDEA 中创建运行web项目

【4、配置tomcat容器】

打开菜单Run -> 选择Edit Configuration

[Intellij] 在IntelliJ IDEA 中创建运行web项目

点击“+”号 -> 选择“Tomcat Server” -> 选择“Local”

[Intellij] 在IntelliJ IDEA 中创建运行web项目

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

[Intellij] 在IntelliJ IDEA 中创建运行web项目

选择tomcat跟路径

[Intellij] 在IntelliJ IDEA 中创建运行web项目

“Server”选项板中,取消勾选”After launch”,设置”HTTP port”和”JMX port”(默认值即可),点击 Apply -> OK, 至此Tomcat配置完成。

[Intellij] 在IntelliJ IDEA 中创建运行web项目

【5、在Tomcat中部署并运行项目 

Run -> Edit Configurations,进入”Run/Debug Configurations”窗口 -> 选择刚刚建立的Tomcat容器 -> 选择Deployment -> 点击右边的“+”号 -> 选择Artifact

[Intellij] 在IntelliJ IDEA 中创建运行web项目

->选择web项目 -> Application context可以填“/firstweb”(其实也可以不填的~~) -> OK

[Intellij] 在IntelliJ IDEA 中创建运行web项目

此时在左下角可见我们刚创建的tomcat和部署的firstweb项目

[Intellij] 在IntelliJ IDEA 中创建运行web项目

右上角也有

[Intellij] 在IntelliJ IDEA 中创建运行web项目

然后我们修改下index.jsp文件查看下访问效果

[Intellij] 在IntelliJ IDEA 中创建运行web项目

启动tomcat

[Intellij] 在IntelliJ IDEA 中创建运行web项目

[Intellij] 在IntelliJ IDEA 中创建运行web项目

然后页面访问下

[Intellij] 在IntelliJ IDEA 中创建运行web项目

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,104
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,580
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,428
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,835
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,918