使用IntelliJ IDEA 14和Maven创建java web项目

安装Maven

下载安装

maven官网下载最新版。

解压到安装目录。

配置

右键桌面的计算机图标,属性–>高级系统设置–>环境变量,添加M2_HOME的环境变量,然后将该变量加入的PATH中。

注意 必须要有JAVA_HOME和个环境变量,不然maven会提示错误。

id="iframe_0.014840382678156905" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131211943.png?attname=&e=1422797138&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:1XRvEZM3617eMd_qoIaP145q49w&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.014840382678156905',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 919px; height: 589px;">

id="iframe_0.865247510088911" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131212150.png?attname=&e=1422797138&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:5C7pUPCV7UvFNUrfhHFG51o767c&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.865247510088911',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 494px; height: 602px;">

id="iframe_0.14387228560322596" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131212514.png?attname=&e=1422797138&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:IW7_L2PDsUM8jUjWJR-X-dR-Jcs&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.14387228560322596',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 450px; height: 546px;">

如果想要修改maven的本地仓库位置,可以在maven的安装目录下的conf目录下的settings.xml配置文件中设置。

id="iframe_0.2527008024309514" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131213204.png?attname=&e=1422797574&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:BZjzLjo1jyvFjIQPpxxJjg90TKE&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.2527008024309514',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 920px; height: 402px;">

打开CMD,输入mvn --version,看到如下提示就说明安装成功了。

id="iframe_0.2348759049347955" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131213547.png?attname=&e=1422797760&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:7nSMl85KYVzWVplBibSOZNE2XUQ&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.2348759049347955',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 661px; height: 407px;">

配置IntelliJ

在IntelliJ的设置中,可以设置maven的安装目录,settings.xml文件的位置,和本地仓库的位置等信息。

id="iframe_0.29680528707781795" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131214059.png?attname=&e=1422798079&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:xoAahXVnOfT6WQ7g0M8HTZzI3vQ&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.29680528707781795',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 870px; height: 683px;">

新建

新建maven项目,create from archetype,选择maven-archetype-webapp

id="iframe_0.7717996494809949" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/2015013101.png?attname=&e=1422795839&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:4DHDuqSA-aqqVZL2ToP-7ZpJwu4&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.7717996494809949',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 748px; height: 602px;">

Next,填写GroupId,ArtifactId和Version

id="iframe_0.4230084340285867" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131210639.png?attname=&e=1422796020&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:ogUmxYsQQgdf3rA68uZWI7IYuv4&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.4230084340285867',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 749px; height: 599px;">

Next,这里在Properties中添加一个参数archetypeCatalog=internal,不加这个参数,在maven生成骨架的时候将会非常慢,有时候会直接卡住。

来自网上的解释:

archetypeCatalog表示插件使用的archetype元数据,不加这个参数时默认为remote,local,即中央仓库archetype元数据,由于中央仓库的archetype太多了,所以导致很慢,指定internal来表示仅使用内部元数据。

id="iframe_0.7184563650574942" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131214447.png?attname=&e=1422798312&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:bfAVtk3dLctPaOCV5gxFNwcoz1E&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.7184563650574942',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 743px; height: 589px;">

Next,填写项目名称和module名称。

id="iframe_0.7099322597334095" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131214955.png?attname=&e=1422798607&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:FL2LEbE_LkhsgNN3F9XkWF6T7qs&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.7099322597334095',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 744px; height: 588px;">

点击Finish。

项目的目录结构如下:

id="iframe_0.5898523159960873" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131215310.png?attname=&e=1422798808&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:tb1Ra30K8DAc56O0_C5WxXY8MGg&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.5898523159960873',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 335px; height: 353px;">

设置

配置项目的JDK和language level

id="iframe_0.6316091714603986" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131215606.png?attname=&e=1422801407&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:Qq36p9NA2tjxI1EgYb5Vn2GSq-Q&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.6316091714603986',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 864px; height: 685px;">

在main文件夹下新建一个java文件夹,把它设为源代码文件夹。

id="iframe_0.4605564556229731" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131215824.png?attname=&e=1422801407&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:w3y6uQiZlUmZRmJAmfI9E54ktjg&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.4605564556229731',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 869px; height: 682px;">

为module添加外部依赖的jar包。

id="iframe_0.8344323658539465" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131220444.png?attname=&e=1422801407&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:Y0vo1r2iVHOd6wEH2zb7idJo37M&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.8344323658539465',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 875px; height: 687px;">

添加tomcat的依赖是为了满足servletjsp依赖的,tomcat作为一个servlet容器提高了servletjsp的API。

id="iframe_0.9461738417883574" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131225335.png?attname=&e=1422802468&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:o9Vd6jSUyu3XdALnNJ5C92u2C_A&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.9461738417883574',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 1064px; height: 520px;">

id="iframe_0.7928288823267537" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131225348.png?attname=&e=1422802468&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:A71Y_CJ-3xN1sh31_m_4praGRQM&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.7928288823267537',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 538px; height: 497px;">

添加jar包依赖。

id="iframe_0.6209425514563915" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131220505.png?attname=&e=1422801407&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:hvi356PNA72drN5DAKrQ6uUYU6E&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.6209425514563915',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 879px; height: 678px;">

设置artifact。

id="iframe_0.4835006701882496" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131220648.png?attname=&e=1422801407&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:679478Vri3aAhyUn8wauXfBns9A&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.4835006701882496',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 868px; height: 677px;">

设置tomcat。

id="iframe_0.14609404872297604" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131220725.png?attname=&e=1422801407&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:8X5Dop_0BMo6iAkoH4N1jWVBbkk&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.14609404872297604',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 1085px; height: 633px;">

id="iframe_0.6488659361149289" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131220857.png?attname=&e=1422801676&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:T3tgvP0D0YNXHWC18ueFYn2ZE4M&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.6488659361149289',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 1079px; height: 628px;">

id="iframe_0.35137038950714383" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://7u2r8z.com1.z0.glb.clouddn.com/20150131224727.png?attname=&e=1422802062&token=bm0aGge7R2WSvVmK5LOvS5P0w6J5-Dt0_YCJMk1I:8UDLUcy9j2tu0p7IPkQp3FI6tb0&_=4658765%22%20style=%22border:none;max-width:1085px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.35137038950714383',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 1076px; height: 615px;">

启动tomca

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值