部署前期準(zhǔn)備:
- 下載intellij idea 2017 IDE開發(fā)工具
- 激活intellij idea 2017 :http://idea.lanyus.com/
- 升級(jí)jdk到8.0
- 安裝tomcat@9.0
- 安裝maven3.5.2
1. 新建maven項(xiàng)目
紅箭頭標(biāo)注的3個(gè)點(diǎn)腊徙,是需要注意的原探,不要選錯(cuò)了或漏掉
image.png
- 待項(xiàng)目下載完成后席揽,修改pom.xml:
junit的版本修改為:4.12
<build>
...
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>//1.8 依據(jù)jdk的版本不同而變化
<target>1.8</target>//1.8 依據(jù)jdk的版本不同而變化
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
- 修改main/webapp/WEB-INF目錄下web.xml文件:
使用下邊代碼替換:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID"
version="3.1">
<display-name>ReflectProject</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
- main/webapp/WEB-INF目錄下添加classes,lib倆個(gè)目錄
-
打開project structure 對(duì)話框:
source標(biāo)簽:
image.png
path標(biāo)簽:
倆個(gè)output path的路徑都設(shè)置為上一步所創(chuàng)建的classes目錄
image.png
dependencies標(biāo)簽:
然后再打開的對(duì)話框中和上一步的lib建立關(guān)系
image.png
選中箭頭的選項(xiàng)赖草,然后ok
-
setting 設(shè)置修改:
箭頭位置修改為jdk當(dāng)前版本
image.png檢查下邊紅框部分的設(shè)置是否正確:
image.png -
右上角下拉框中的edit configuration 設(shè)置:
image.png
image.png
image.png
按照上邊步驟完成后可以啟動(dòng)服務(wù)了,順利的話车伞,會(huì)自動(dòng)打開瀏覽器碧查,頁(yè)面顯示Hello World! ,第一個(gè)java項(xiàng)目就完成了耗帕。