在eclipse中用maven创建web项目。

环境配置

C:\Users\xxx>java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

C:\Users\xxx>mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: C:\apache-maven-3.3.9\bin\..
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: C:\Java\jdk1.8.0_121\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"

Eclipse Java EE IDE for Web Developers.

Version: Neon.2 Release (4.6.2)
Build id: 20161208-0600

创建maven project

eclipse maven web-LMLPHP

输入必要信息后,点Finish

(图中有误!Packaging处应该选择war)

eclipse maven web-LMLPHP

编码改成UTF-8,然后点击OK

eclipse maven web-LMLPHP

删除JRE 1.5

eclipse maven web-LMLPHP

加入JRE 1.8依赖

eclipse maven web-LMLPHP

eclipse maven web-LMLPHP

编译级别改为1.8

eclipse maven web-LMLPHP

eclipse maven web-LMLPHP

设置project facets

eclipse maven web-LMLPHP

eclipse maven web-LMLPHP

eclipse maven web-LMLPHP

在Java Build Path中删除无用依赖

eclipse maven web-LMLPHP

在Java Build Path中加入Server Runtime依赖

eclipse maven web-LMLPHP

eclipse maven web-LMLPHP

建个JSP

eclipse maven web-LMLPHP

运行

eclipse maven web-LMLPHP

访问 http://localhost/model/index.jsp

eclipse maven web-LMLPHP

05-08 15:01