天天看點

Intellij2016建立maven的web項目

1、 file->new->project進入以下頁面,注意在最上方要選擇jdk的版本。

Intellij2016建立maven的web項目

2、 填寫GroupId和ArtifactId。這兩個的作用就是maven用以辨別此項目,如果把項目放到本地Maven倉庫中,如圖所填寫,就可以根據cn.test.hello來找到該項目。

Intellij2016建立maven的web項目

3、 添加本地已安裝的 maven及倉庫。

Intellij2016建立maven的web項目

點選加号,添加maven屬性。

Intellij2016建立maven的web項目

4、 輸入項目名和項目存放的位置。

Intellij2016建立maven的web項目

5、 finish之後,file->project Structure->modules,添加完整檔案夾。

src下建立檔案夾test。

Intellij2016建立maven的web項目

main檔案夾下建立java,test檔案加下建立java和resources。

Intellij2016建立maven的web項目

6、 把main檔案夾下的java設為Source Folders,resources設為resources Folders.

Intellij2016建立maven的web項目

7、 把test檔案夾下java設為tests,resources設為test resources Folders。

Intellij2016建立maven的web項目

8、 file->project Structure->artifacts

Intellij2016建立maven的web項目

選擇建立的項目,apply

9、 file->project Structure->facets

點選web resource directory,選擇src->main下的webapp.

Intellij2016建立maven的web項目

10、 tomcat配置。

點選右上角的箭頭,edit configuration

Intellij2016建立maven的web項目
Intellij2016建立maven的web項目

選擇deployment,點選+号

Intellij2016建立maven的web項目

輸入通路路徑,apply.

Intellij2016建立maven的web項目

選擇server. Name用于給tomcat取名,IntelliJ是一個項目配置一個tomcat,取名後便于區分。Configuration選擇本地tomcat路徑,HttpPort配置通路端口。

Intellij2016建立maven的web項目

另想更新頁面後不用重新開機tomcat,在on “update” action 選擇redeploy.

Intellij2016建立maven的web項目

結束。