Eclipse配置maven web项目问题总结
clipse创建Maven结构的web项目的时候选择Artifact Id为maven-artchetype-webapp,点击finish之后,一般会遇到如下问题
1. The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 错误,
这是eclipse环境里没有SeverRuntime导致的,在BuildPath里加入即可,如下图:
添加前:
选择 add library
选择 Apache Tomcat V7.0 并点击 next
点击finish之后,完成添加如下图
2. 如何Maven创建动态Web项目后产生的版本不匹配的问题
我们用Eclipse创建Maven结构的web项目的时候选择了Artifact Id为maven-artchetype-webapp,由于这个catalog比较老,用的servlet还是2.3的、java版本是1.5的,而一般现在至少都是3.0/1.7,因此我们需要逐个修改!
(1) 修改JRE 版本
Go to project Build Path and change the Java Library version to 1.7
删除原先的低版本JRE,并添加workplace默认的版本(JDK1.7),完成后如下:
(2) Eclipse Preferences -> Java -> Compilre -> Change compliance level to 1.7
(3) 修改 Project Facets 版本(注意顺序)
在项目上单机右键 -> Properties -> Project Facets -->取消选中 Dynamic Web Module 状态,点击 Apply -->将 Javafacet 版本变为 1.7 ,点击 Apply如下图
-->将 Dyanmic Web Module 版本更改为3.0, 点击 Apply.
此时会有较大几率提示: web.xml is missing and <failOnMissingWebXml> is set to true,如下图
解决办法,在项目上单击右键-->java EE Tools ---> Generate Deployment Descriptro Stub
OK 问题解决
3. 解决发布之后404错误
默认情况下因为默认的deployment assembly中 webapp路径的问题,如下图可以看到默认的webapp下的页面都被发布到WEB-INF/class下了,
导致出现了如下图的目录结构,所以所有的jsp都无法访问以及通过web.xml加载的ssm环境无法初始化!
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source'
出现SetPropertiesRule警告的原因是因为Tomcat在server.xml的Context节点中不支持source属性:<Context docBase="…" path="/…" source="org.eclipse.jst.j2ee.server:…"/>
解决方法是在Servers视图里双击创建的server,然后在其server的配置界面中选中"Publish module contexts to separate XML files"选项。
具体“Publish module contexts to separate XML files”是什么意思,
请看Tomcat Publishing Options介绍:
Two new options which affect publishing are now available in the Server Options section of the Tomcat server editor. The Tomcat server must be 5.0.x or later for these options to be enabled. The Serve modules without publishing option does what it says. Web content will be served directly from the "WebContent" folder of the Dynamic Web Project. A customized context is used to make the project's dependencies available in the Web application's classloader. The Publish module contexts to separate XML files option will publish contexts using the preferred method of separate XML files under the "conf/Catalina/localhost" directory, rather than keeping them in the "server.xml" file. A couple of improvements for this option are noted in Bugs 180931 and 180936.
关于解决方法,再详细说明一下:
Servers视图的打开方法:Window--Show View-other..--Servers
双击Server:就是双击服务器名,我的服务器名为:Tomcat v6.0 Server at localhost 即双击它,进入
server的配置界面: 选中"Publish module contexts to separate XML files"选项
web.xml is missing and <failOnMissingWebXml> is set to true解决方法
这种错误是因为maven默认简单构建项目是sevlet3.0版本,web.xml不是必须的,这时候需要手动创建webapp/WEB-INF/web.xml,web.xml可以从其他项目复制一个过来改改,
或者pom.xml添加如下配置
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
修改完了别忘了右键项目Mavan/update project..
Eclipse配置maven web项目问题总结的更多相关文章
- Eclipse 搭建 Maven Web项目
第一步:安装JDK: 第二步:安装Eclipse: 第三步:安装tomcat7: 第四步:安装maven插件: 4.1 下载maven:http://maven.apache.org/download ...
- eclipse创建maven web项目
eclipse创建maven web项目: 1.安装eclipse maven插件 2.新建maven project选择webapp模板. 3.改造为maven文档结构. 4.添加项目的JAVAEE ...
- Eclipse创建Maven Web项目 + 测试覆盖率 + 常见问题(2015.07.14——湛耀)
Eclipse创建Maven web项目: 到此,并没有创建好,接下来一步步解决问题: 问题:无法创建src/main/java目录 解决: 右键项目选择[properties] 点击[OK] 问题: ...
- 解决使用eclipse创建maven web项目时报Could not resolve archetype的问题
前两天重装了系统,今天想写一个项目的时候出现了点问题. 在使用eclipse创建maven web项目时,点Finish后报了Could not resolve archetype的问题. Could ...
- Java归去来第2集:利用Eclipse创建Maven Web项目
一.前言 如果还不了解剧情,请返回第一集的剧情 Java归去来第1集:手动给Eclipse配置Maven环境 二.利用Eclipse创建Maven Web项目 选择File-New- ...
- eclipse 创建maven web项目
参考:http://www.cnblogs.com/hongwz/p/5456616.html eclipse 创建maven web项目
- Eclipse创建Maven Web项目后更改Servlet版本
Eclipse创建Maven Web项目后更改Servlet版本 1.场景基于Eclipse通过maven-archetype-webapp原型创建一个Web项目后,其默认Servlet版本是2.3, ...
- eclipse中maven web项目部署时缺少classes文件或者resources文件
写这篇博客的原因 问题描述 昨天发现eclipse中maven web项目部署时缺少classes文件或者resources文件 本来以为是很常见的原因, 依次检查"Java Build P ...
- eclipse创建maven web项目工程步骤示例
参考链接:https://www.cnblogs.com/noteless/p/5213075.html 需求表均同springmvc案例 此处只是使用maven 注意,以下所有需要建立在你的ecli ...
随机推荐
- Service Broker 概述
ServiceBroker(简称SSB)是基于数据库引擎提供的一个强大的异步编程模型,通过ServiceBroker,开发人员无需编写复杂的通信和消息程序,即可在数据库实例之间完成高效可靠的异步通信. ...
- sharpsvn 继续,解决文件locked 问题,
方法中少个方法就会出现一些问题. 比如进行了断线测试,结果再操作时就出现了文件被锁的情况,最终查了官网的论坛,才得以解决 How to unlock if the working copy is lo ...
- Linux apt-get命令
一.简介 Ubuntu系列系统包管理工具. 二.常用指令 1.查询功能 apt-cache search package 搜索软件包 apt-cache show package 获取包的相关 ...
- hdu 5129 (枚举) The E-pang Palace
题目;http://acm.hdu.edu.cn/showproblem.php?pid=5128. 给你n个点,问能否组成两个不相交的与坐标轴平行的矩形,能就输出两矩形的面积和,不能就输出一个字符串 ...
- Windows下的PHP 5.3.x安装 Zend Guard Loader
PHP5.3之后不再使用Zend Optimizer而是由Zend Guard Loader替换,而Zend Guard Loader安装比前者方便了很多,只有一个dll: 址:http://down ...
- swift NSdata 转换 nsstring
result = NSString(data: data, encoding: NSUTF8StringEncoding) 做HTTP 请求时 遇到 打印结果看 所以~~~
- Capacity To Ship Packages Within D Days LT1011
A conveyor belt has packages that must be shipped from one port to another within D days. The i-th p ...
- Maximum Average Subarray I LT643
Given an array consisting of n integers, find the contiguous subarray of given length k that has the ...
- centos下安装nodejs
1.首先要安装gcc, # yum install libtool automake autoconf gcc-c++ openssl-devel 2.可以进入某个目录,下载NodeJS v0.10. ...
- 【算法】BFS+哈希解决八数码问题
15拼图已经有超过100年; 即使你不叫这个名字知道的话,你已经看到了.它被构造成具有15滑动砖,每一个从1到15上,并且所有包装成4乘4帧与一个瓦块丢失.让我们把丢失的瓷砖“X”; 拼图的目的是安排 ...