无法将项目方面动态 Web 模块的版本更改为 2.5 [英] Cannot change version of project facet Dynamic Web Module to 2.5

查看:24
本文介绍了无法将项目方面动态 Web 模块的版本更改为 2.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从另一家公司继承了一个 Java 网络应用程序.我正在尝试将其加载到 Eclipse(通过导入 Maven 项目)中,并收到一条错误消息,提示无法将项目方面动态 Web 模块的版本更改为 2.5".

I've inherited a Java web app from another company. I'm trying to load it into Eclipse (via Import Maven Project), and getting an error that says "Cannot change version of project facet Dynamic Web Module to 2.5".

我一直在摸索,我发现的一件事是 web.xml 文件以

I've been poking around a little, and one thing I'm finding is that the web.xml file starts with

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" version="2.5">

并且 pom.xml 指定了

and the pom.xml specifies a dependency of

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>

但是 .settings 文件夹包含一个文件

but the .settings folder contains a file with this

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
  <fixed facet="wst.jsdt.web"/>
  <installed facet="java" version="1.6"/>
  <installed facet="jst.web" version="3.0"/>
  <installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>

我怀疑这里指定的 3.0 与其他地方指定的 2.5 冲突.有可能是这种情况吗?这种设置组合有什么办法不会导致错误吗?(旧版本的 Eclipse,例如?)

and I suspect that the 3.0 specified here is conflicting with the 2.5 specified elsewhere. Is that likely to be the case? Is there any way this combination of settings could NOT result in errors? (Older version of Eclipse, eg?)

推荐答案

短版

试试这个:

  • 取消选择项目构面中的动态 Web 模块.右键单击项目 -> 首选项 -> 项目构面
  • 然后再次运行 Maven -> 更新项目.

长版

我在学习一些 eclipse 动态 web/spring 的东西时遇到过这个问题很多次,其他解决方案都没有可靠地解决我的问题或帮助我了解导致问题的原因.我想我开始了.

I've had this problem a number of times while learning some eclipse dynamic web/spring stuff and none of the other solutions fixed my issue reliably or helped me understand what was causing the issue. I think I am beginning to.

因此,当您运行 Maven -> 更新项目时,m2e(我假设)正在将动态 Web 模块添加到项目方面.添加是这里的关键词.所以当我进去更新 web.xml从[...] http://java.sun.com/xml/ns/javaee/web-app_2_3.xsd" version="2.3">到[...] http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

So it appears that when you run a Maven -> Update Project, m2e (I assume) is ADDING the Dynamic Web Module to the Project Facets. Adding is the key word here. So when I went in and updated web.xml from [...] http://java.sun.com/xml/ns/javaee/web-app_2_3.xsd" version="2.3"> to [...] http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

我收到错误消息无法将项目方面动态 Web 模块的版本更改为 2.5."

I got the error "Cannot change version of project facet Dynamic Web Module to 2.5."

当我尝试 3.0 时也是如此.

Same was true for 3.0 when I tried that.

看起来 m2e 能够将它添加到您的项目中,但就像错误所说的那样,一旦设置它就无法更改.所以只需在项目方面页面中取消选择它.点击OK保存您的首选项并再次运行 Maven 更新.

It appears m2e is capable of adding this to your project but like the error says it is unable to change it once it is set. So simply deselect it in the project facets page. Hit O.K. to save your preferences and run Maven Update again.

如果您添加了服务器(如 tomcat)方面,则不应该需要在 pom.xml 中包含 javax.servlet.

You shouldn't need to include javax.servlet in your pom.xml if you have a server (like tomcat) facet added.

这篇关于无法将项目方面动态 Web 模块的版本更改为 2.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆