Maven学习笔记-使用Eclipse插件创建Java Webapp项目
Posted 文子的天空
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Maven学习笔记-使用Eclipse插件创建Java Webapp项目相关的知识,希望对你有一定的参考价值。
使用 Java 的猿们,最多接触的大概就是 web 项目了吧?在学习 Maven 的过程中,首先当然就是创建一个 webapp 项目。
自己在尝试的过程中,碰到了很多的问题。我把详细的过程都记录下来,以便今后参考。




<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build>
(也可以通过修改 settings.xml 全局配置以让 Maven 默认设置特定版本的 JRE,具体方法这里先不写了)


这时只要将 Libraries 标签中的 JRE System Library 设置为本机默认的就可以解决该错误(不知道为什么会这样)

双击 JRE System Library 项,弹出 JRE 设置界面:↓↓↓


The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

在弹出的对话框中,选择“Server Runtime”。

选择 Tomcat 服务器。如果这里没有服务器配置,请事先配置一个 Tomcat 等服务器。
(不知道如何配置服务器的话,就用搜索引擎搜一番)。

选中 Tomcat,点击 Finish 后,看到工程已经不再有那两个 Servlet 的报错了。
Java compiler level does not match the version of the installed java project facet.

我们需要通过修改 Project Facets 来解决这个错误。


Cannot change version of project facet Dynamic Web Module to 3.0

这时项目应该已经配置到服务器中了:




最后,我也不知道为什么,似乎很简单的事情,会变得如此复杂。
以上是关于Maven学习笔记-使用Eclipse插件创建Java Webapp项目的主要内容,如果未能解决你的问题,请参考以下文章
Maven01_02_.Eclipse支持Maven怎么判断我的eclipse支不支持Maven创建一个简单的Maven项目Maven命令行的使用jdk里面是包含jre的