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

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

问题描述

我继承了另一家公司的Java Web应用程序。我试图将它加载到Eclipse(通过导入Maven项目),并得到一个错误,说无法将项目构面动态Web模块的版本更改为2.5。



我一直在戳一点,有一件事我发现web.xml文件是以

$ $ $ $ $ $ $ $ $ $ $ $ < web-app xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance
xmlns =http://java.sun.com/xml/ns/javaeexmlns :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_IDversion =2.5>

,pom.xml指定了一个依赖关系

 <依赖关系> 
< groupId> javax.servlet< / groupId>
< artifactId> servlet-api< / artifactId>
< version> 2.5< / version>
< scope>已提供< / scope>
< / dependency>

但.settings文件夹包含一个这样的文件

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

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

解决方案

简版



尝试这样:




  • 取消选择项目构面中的动态Web模块。
    右键单击项目 - >首选项 - >项目构面

  • 然后再次运行 Maven - >更新项目 / li>


长版本



我有这个问题了很多次学习一些eclipse的动态网页/弹簧的东西,没有其他的解决方案可靠地解决我的问题,或帮助我了解导致这个问题的原因。我想我开始了。



所以看来,当你运行一个 Maven - >更新项目时,m2e(我假设)是ADDING动态Web模块到项目方面。添加是这里的关键词。所以当我进入并更新web.xml

[...] 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。



当我尝试这样的时候,3.0也是如此。



看来,m2e能够将这个添加到你的项目中,但是错误说它是不可能的一旦设置,就更改。所以只需在项目facets页面中取消选择它。命中保存您的首选项并再次运行Maven Update。



需要将javax.servlet包含在您的pom.xml中(<如tomcat)facet added。




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".

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">

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>

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>

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?)

解决方案

short version

Try this:

  • Deselect the Dynamic Web Module in your project facets. Right click the Project -> preferences -> Project Facets
  • Then run Maven -> Update Project again.

Long Version

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.

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">

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

Same was true for 3.0 when I tried that.

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.

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

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

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