idea创建maven web 项目
2019-06-14 本文已影响0人
santree
idea创建maven web 项目
1.创建一个新项目
![](https://img.haomeiwen.com/i6655874/c97940157c20c424.png)
2.选择创建maven项目
![](https://img.haomeiwen.com/i6655874/2ebdb4c7350cfe84.png)
3.输入公司名和模块名(自定义即可)
![](https://img.haomeiwen.com/i6655874/381aac10dc12e071.png)
4.选择maven安装目录
选择maven配置文件位置。配置文件settings.xml配置有本地仓库地址。如何配置maven本地仓库地址请看《maven设置本地仓库》一文。
![](https://img.haomeiwen.com/i6655874/72d96387dff64e59.png)
5.填写项目名称和项目位置
点击fished。因为idea设置问题,有些需要点击import changes。左边目录结构出现如图,说明项目构建已完成。
![](https://img.haomeiwen.com/i6655874/2dfa3d6191ab86de.png)
![](https://img.haomeiwen.com/i6655874/5e468b5e7375be5e.png)
![](https://img.haomeiwen.com/i6655874/ab68bc34581fd05b.png)
6.添加模块
点击File - Project Structure - modules - 点击+号 - 选择web
![](https://img.haomeiwen.com/i6655874/2f6d0d8c29d3c7c2.png)
![](https://img.haomeiwen.com/i6655874/8d7c216024e69172.png)
![](https://img.haomeiwen.com/i6655874/1663517877bc5ba2.png)
![](https://img.haomeiwen.com/i6655874/97df44593cf494c0.png)
7.添加Artifacts
Artifacts是maven中的一个概念,表示某个module要如何打包,例如war exploded、war、jar、ear等等这种打包形式;
一个module有了Artifacts就可以部署到应用服务器中。
点击Artifacts - Web Appplication:Exploded - from Modules
![](https://img.haomeiwen.com/i6655874/fd51a0bd91eeb95f.png)
![](https://img.haomeiwen.com/i6655874/81ed0278ad41dba5.png)
8.点击Add Configuration - 配置Tomcat服务器
![](https://img.haomeiwen.com/i6655874/6b560e3f06aae7ee.png)
![](https://img.haomeiwen.com/i6655874/498791b0725ece0e.png)
9.配置服务器相关信息
HTTP port 为Tomcat服务器默认端口,若tomcat服务器端口修改过,此处要对应修改。
![](https://img.haomeiwen.com/i6655874/a254a8f13d6e242a.png)
10.部署项目
点击deployment部署项目 - 点击右侧的+号 - 选择war exploded
![](https://img.haomeiwen.com/i6655874/25fbbf0d8d1bc87b.png)
![](https://img.haomeiwen.com/i6655874/81faad301142792c.png)
11.启动服务器
可以看到服务器已配置完成,点击右上方绿色小三角运行服务器。
![](https://img.haomeiwen.com/i6655874/ebf1aac0108a8a28.png)
12.运行成功
-浏览器弹出 hello world 界面
![](D:\个人\学习\笔记\图片\idea新建maven web项目20.png)
![](https://img.haomeiwen.com/i6655874/f57ec588d49e9703.png)