Eclipse - 如何将“项目方面”从 Tomcat 6 更改为 Tomcat 5.5?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/75786/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 18:22:58  来源:igfitidea点击:

Eclipse - How can I change a 'Project Facet' from Tomcat 6 to Tomcat 5.5?

eclipsetomcattomcat6tomcat5.5ganymede

提问by user13360

(Eclipse 3.4, Ganymede)

(Eclipse 3.4,木卫三)

I have an existing Dynamic Web Application project in Eclipse. When I created the project, I specified 'Default configuration for Apache Tomcat v6' under the 'Configuration' drop down.

我在 Eclipse 中有一个现有的动态 Web 应用程序项目。创建项目时,我在“配置”下拉菜单下指定了“Apache Tomcat v6 的默认配置”。

It's a month or 2 down the line, and I would now like to change the configuration to Tomcat 'v5.5'. (This will be the version of Tomcat on the production server.)

一两个月后,我现在想将配置更改为 Tomcat 'v5.5'。(这将是生产服务器上的 Tomcat 版本。)

I have tried the following steps (without success):

我尝试了以下步骤(没有成功):

  • I selected Targeted Runtimesunder the Project Properties
    The Tomcat v5.5option was disabled and The UI displayed this message:
    If the runtime you want to select is not displayed or is disabled you may need to uninstall one or more of the currently installed project facets.
  • I then clicked on the Uninstall Facets...link.
    Under the Runtimestab, only Tomcat 6displayed.
    For Dynamic Web Module, I selected version 2.4in place of 2.5.
    Under the Runtimestab, Tomcat 5.5now displayed.
    However, the UI now displayed this message:
    Cannot change version of project facet Dynamic Web Module to 2.4.
    The Finishbutton was disabled - so I reached a dead-end.
  • Targeted Runtimes在 Project 下选择了Properties
    Tomcat v5.5选项被禁用并且 UI 显示此消息:
    If the runtime you want to select is not displayed or is disabled you may need to uninstall one or more of the currently installed project facets.
  • 然后我点击了Uninstall Facets...链接。
    Runtimes选项卡下,仅Tomcat 6显示。
    对于Dynamic Web Module,我选择了版本2.4来代替2.5.
    Runtimes选项卡下,Tomcat 5.5现在显示。
    然而,现在的用户界面显示这样的信息:
    Cannot change version of project facet Dynamic Web Module to 2.4.
    Finish按钮被禁用-让我达到了一个死胡同。

I CAN successfully create a NEW Project with a Tomcat v5.5 configuration. For some reason, though, it will not let me downgrade' an existing Project.

我可以使用 Tomcat v5.5 配置成功创建一个新项目。但是,出于某种原因,它不会让我降级现有的项目。

As a work-around, I created a new Project and copied the source files from the old Project. Nonetheless, the work-around was fairly painful and somewhat clumsy.

作为一种解决方法,我创建了一个新项目并从旧项目中复制了源文件。尽管如此,解决方法相当痛苦,而且有些笨拙。

Can anyone explain how I can 'downgrade' the Project configuration from 'Tomcat 6' to 'Tomcat 5'? Or perhaps shed some light on why this happened?

谁能解释我如何将项目配置从“Tomcat 6”“降级”到“Tomcat 5”?或者也许可以阐明为什么会发生这种情况?

Thanks
Pete

感谢
皮特

回答by William

This is kind of hacking eclipse and you can get into trouble doing this but this should work:

这是一种黑客日食,你可能会遇到麻烦,但这应该有效:

Open the navigator view and find that there is a .settings folder under your project expand it and then open the file: org.eclipse.wst.common.project.facet.core.xmlyou should see a line that says: <installed facet="jst.web" version="2.5"/> Change that to 2.4 and save.

打开导航器视图,发现您的项目下有一个 .settings 文件夹,展开它,然后打开文件:org.eclipse.wst.common.project.facet.core.xml您应该看到一行说:将其 <installed facet="jst.web" version="2.5"/> 更改为 2.4 并保存。

Just make sure that your project isn't using anything specific for 2.5 and you should be good.

只要确保你的项目没有使用任何特定于 2.5 的东西,你就应该很好。

Also check your web.xml has the correct configuration:

还要检查您的 web.xml 是否具有正确的配置:

<web-app version="2.4" 
        xmlns="http://java.sun.com/xml/ns/j2ee" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

回答by Venkat

This may be old but I tried and found the following in eclipse Galilio.

这可能是旧的,但我在 eclipse Galilio 中尝试并发现了以下内容。

Open the navigator view and find that there is a .settings folder under your project expand it and then open the file: org.eclipse.wst.common.project.facet.core.Delete the content of this file and right click on the project and click on properties. Go to Project Facats in the popup window there you can click on runtime tabs and convert your project to the new facet you want.

打开navigator视图,发现你的项目下有一个.settings文件夹展开它然后打开文件:org.eclipse.wst.common.project.facet.core.删除这个文件的内容,在项目上右键然后点击属性。转到弹出窗口中的 Project Facats,您可以单击运行时选项卡并将您的项目转换为您想要的新方面。

回答by Karthik

if you are using Maven, then shutdown eclipse, then type >mvn eclipse:eclipse -Dwtpversion=2.0, and restart the eclipse.

如果您使用的是 Maven,则关闭 eclipse,然后键入>mvn eclipse:eclipse -Dwtpversion=2.0,然后重新启动 eclipse。

回答by sarabrab

I saw the same thing, then I changed the web-app version value in the web.xml. Doing so could fix this for you.

我看到了同样的事情,然后我在web.xml. 这样做可以为您解决这个问题。

回答by xgomez

You can try to uncheck the facet, apply, change the value of the facet and check. It works for me in Eclipse Helios SR1.

您可以尝试取消选中构面,应用,更改构面的值并检查。它在 Eclipse Helios SR1 中对我有用。

So the main difference is that I do it with 'Dynamic Web Module'.

所以主要的区别是我用“动态网络模块”来做。

I hope it works for you too.

我希望它也适用于你。

回答by William

Sorry it seems I can't post a comment without enough Rep so...

抱歉,如果没有足够的代表,我似乎无法发表评论,所以...

I think it's too difficult for eclipse to degrade safely to a lower standard because it can't really know if you've used something from the newer web standard. So if it just allows you do to that it could cause your program to fail on an older version.

我认为 eclipse 很难安全地降级到较低的标准,因为它无法真正知道您是否使用了较新的 Web 标准中的某些内容。因此,如果它只是允许您这样做,则可能会导致您的程序在旧版本上失败。

You can always be backward compatible but not forwards compatible.

您始终可以向后兼容,但不能向前兼容。

回答by Dante

If you are using maven you can generated the eclipse settings using the maven eclipse plugin.

如果您使用的是 maven,则可以使用 maven eclipse 插件生成 eclipse 设置。

For the jst.web version the Maven eclipse pluging takes into account the dependencies of the project. If you have a servlet api dependency defined :

对于 jst.web 版本,Maven eclipse 插件会考虑项目的依赖关系。如果您定义了 servlet api 依赖项:

<dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>servlet-api</artifactId>
    <version>6.0.32</version>
</dependency> 

You jst.web parameter will be 6.0

你的 jst.web 参数将是 6.0

<faceted-project>
  ...
  <installed facet="jst.web" version="6.0"/>
  ...
</faceted-project>