方法/步驟
-
new --> other
-
1、Wizards: mvaen
2、Maven Project
3、Next
-
Use Default Workspace Location
-
1、webapp
2、maven-archetype-webapp
3、next
-
1、輸入Group Id
2、輸入Artifact Id
3、Finish
-
這時候會看到文件報錯,解決辦法如圖:
在Pom中添加Servlet
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
添加完成之后Ctrl+S保存
-
Junit版本修改 及 Servlet 只在編譯和測試時運行
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<!-- 只在編譯和測試時運行 -->
<scope>provided</scope>
</dependency>
-
可以看出Maven項目不全
下面是補全項目的方法
1、選中項目,單擊鼠標右鍵 New-->Folder
src/main/java
src/test/java
2、選中項目,單擊鼠標右鍵 New-->Source Folder
src/test/resources
-
項目檢查 檢查輸出路徑
-
轉換成Web項目
-
刪除不需要的輸出文件
-
項目創建完成
END



















