Intellij idea中创建maven项目

Intellij idea中创建maven项目

  一.打开IDEA设置

Intellij idea中创建maven项目_第1张图片 

二.解决创建Maven项目速度慢的问题

       在MAVEN的VM Options内添加-DarchetypeCatalog=internal 运行参数 ,可选值为:remote,internal,local等。用来指定archetype-catalog.xml文件从哪里获取,默认为remote,即从 http://repo1.maven.org/maven2/archetype-catalog.xml路径下载archetype-catalog.xml文件。这里是针对所有项目而言。

Intellij idea中创建maven项目_第2张图片

三.创建新项目

        1.选择File->New->Project

Intellij idea中创建maven项目_第3张图片

        2.勾选Create from archetype后选择maven-archetype-webapp

Intellij idea中创建maven项目_第4张图片

        3.填写maven项目的GroupId,ArtifactId,Version信息。这是标识maven项目的三维坐标。点击Next

Intellij idea中创建maven项目_第5张图片

        4.需要添加一个archetypeCatalog=internal。这个参数的意义是让这个maven项目的骨架不要到远程下载archetype-catalog.xml而是本地获取。如果你没加这个参数,那么项目创建可能在卡在downloading maven plugins...继续点击Next

Intellij idea中创建maven项目_第6张图片

        5.填入项目名称和项目目录,点击finish

Intellij idea中创建maven项目_第7张图片

        6.可以看到项目目录已经自动生成,点击Import Changes

Intellij idea中创建maven项目_第8张图片

        7.点击idea右侧Maven Projects里面install运行项目。可以看到生成war包。项目创建完成

Intellij idea中创建maven项目_第9张图片

四. 配置项目结构

         1.选择File——>Project Structure     

Intellij idea中创建maven项目_第10张图片

            2.选择Modules里面sources,在main目录下新建文件夹,创建完成点击sources(存放java代码)

Intellij idea中创建maven项目_第11张图片        Intellij idea中创建maven项目_第12张图片

            3.配置Facets(默认)

Intellij idea中创建maven项目_第13张图片

五.配置Tomcat

             1.选择Edit Configurations

Intellij idea中创建maven项目_第14张图片

            2.选择Tomcat Server——>Local

Intellij idea中创建maven项目_第15张图片

            3.选择Deloyment,点击+选择 Artifact 里面war:exploded             

Intellij idea中创建maven项目_第16张图片Intellij idea中创建maven项目_第17张图片

            4.配置Application context项目路径

Intellij idea中创建maven项目_第18张图片

            5.自定义name属性,配置Tomcat热启动

Intellij idea中创建maven项目_第19张图片

六.运行项目,跳转浏览器,显示HelloWorld。

Intellij idea中创建maven项目_第20张图片


你可能感兴趣的:(idea,web,maven,tomcat)