eclipse构建maven web项目步骤


新建maven web项目报如下图错误时


eclipse构建maven web项目步骤

去浏览器搜索maven*仓库如下图所示

eclipse构建maven web项目步骤

然后在文本框输入servlet 单机Search如下图所示

eclipse构建maven web项目步骤

然后选择Java Servlet API 如下图所示

eclipse构建maven web项目步骤

然后选择最新版本4.0.0如图所示

eclipse构建maven web项目步骤

然后选择Maven里面的代码如图所示

eclipse构建maven web项目步骤

复制到pom.xml如图所示

eclipse构建maven web项目步骤

然后更改<version>3.8.1</version>改为4.10如图所示

eclipse构建maven web项目步骤

然后创建如图以下等目录

eclipse构建maven web项目步骤

当这种目录无法创建时选择Navigator如图所示

eclipse构建maven web项目步骤

然后单机此项目选择maven这个选项选择Update project这个选项如图所示

eclipse构建maven web项目步骤

单机OK后如图所示

eclipse构建maven web项目步骤

然后在pom.xml添加jetty插件(jetty插件在maven*仓库搜索jetty::jetty maven plugin如servlet一样)如图所示

eclipse构建maven web项目步骤


然后测试是否成功如图所示

eclipse构建maven web项目步骤

run之后如图所示eclipse构建maven web项目步骤

然后在浏览器输入:localhost:8080/  在页面显示 

Hello World!

则表示成功

然后在浏览器打开Tomcat官网选择 Maven Plugin 后如图所示

eclipse构建maven web项目步骤

然后选择  Version2.2 然后复制如下代码到pom.xml
  <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
     <version>2.2</version>
并注释jetty插件  如图所示
eclipse构建maven web项目步骤

然后单机此项目项目运行(同测试运行一样)并在浏览器力输入:localhost:8080/demo 页面出现

Hello World!

表示运行成功!