版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37358860/article/details/89236934
eclipse使用maven构建web3.1项目
一. 使用eclipse创建maven项目
二. 项目创建完成之后,是有错误的,我们需要构重新构建项目,更改jdk,添加lib
- 在项目上右键,Build Path / Configure Build Path
- 更改jdk为1.8
-
添加rumtime library
-
项目构建完成
-
在项目上右键,Build Path / Configure Build Path, 此时查看项目构建,为2.3.
三.更改为3.1
- 在pom.xml文件中添加server依赖
<!-- servlet api -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
- 更改web.xml中的文件头信息,将原来的全部删除,替换为以下代码
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
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>Archetype Created Web Application</display-name>
</web-app>
- 将视图显示切换为Navigator, window / show view / other
- 在Navigator视图中更改org.eclipse.wst.common.project.facet.core.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.8"/>
<installed facet="jst.web" version="3.1"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>
-
在项目上右键,Build Path / Configure Build Path,(此处可以在之前更改)
-
在项目上右键,Build Path / Configure Build Path, 此时查看项目构建,为3.1