将 Java 项目转换为动态 Web 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/838707/
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
Converting a Java Project to a Dynamic Web Project
提问by Mike
I'm using Eclipse Ganymede to create a web application, but the project's currently just a standard Java project. I want to convert it to a Dynamic Web Project and I need a hand in doing that.
我正在使用 Eclipse Ganymede 创建一个 Web 应用程序,但该项目目前只是一个标准的 Java 项目。我想将它转换为动态 Web 项目,我需要帮助它。
I've had suggestions given to me about editing the .project file, but when I restart Eclipse it refuses to open the project claiming the file is corrupt. There's also no facet management options in the project properties.
我收到了有关编辑 .project 文件的建议,但是当我重新启动 Eclipse 时,它拒绝打开声称该文件已损坏的项目。项目属性中也没有方面管理选项。
Any suggestions?
有什么建议?
采纳答案by Mike
Well. I'll tellyou why, folks. It's because a lot of these guides miss out some fundamental things.
好。我会告诉你为什么,伙计们。这是因为很多这些指南都遗漏了一些基本的东西。
Yes, you need to change the .project file to add some missing natures and builders (create a new Dynamic Web Project and examine the created .project file to see what's missing).
You also need to add things to the .settings folder. It'll be missing two or three files, one of which is a key xml file. They're all required for it to understand the new natures you've given it.
是的,您需要更改 .project 文件以添加一些缺少的性质和构建器(创建一个新的动态 Web 项目并检查创建的 .project 文件以查看缺少的内容)。
您还需要向 .settings 文件夹添加内容。它将丢失两三个文件,其中一个是关键的 xml 文件。它们都需要它来理解你赋予它的新性质。
Huzzah for computers.
计算机的 Huzzah。
回答by vrm
Although this question is already answered I'd like to say that I managed to convert my project into web project by changing project facets Properties->Project Facet and just checked Dynamic Web Module
虽然这个问题已经得到回答,但我想说我通过更改项目方面的属性->项目方面并刚刚检查了动态 Web 模块,设法将我的项目转换为 Web 项目
回答by Joost
When you cannot add the "Dynamic Web Module" via "Project Facets" make sure you unlock and disable the "Utility Module" since they are mutually exclusive.
当您无法通过“Project Facets”添加“Dynamic Web Module”时,请确保解锁并禁用“Utility Module”,因为它们是互斥的。
I've spend quite sometime (re)editing the raw .project-file (according to the earlier mentioned sites) until I discovered this. It was probably was set when I was messing with my maven configuration.
我花了很长时间(重新)编辑原始 .project 文件(根据前面提到的网站),直到我发现这一点。它可能是在我弄乱我的 Maven 配置时设置的。
回答by user2842014
Run on server option is not displaying in eclipse .
Run on server 选项未显示在 eclipse 中。
The solution for it that i found is " check Project properties / Project Facets / Dynamic Web module" . For this we need to unlock utility module and then check Dynamic Web Module.
我找到的解决方案是“检查项目属性/项目构面/动态 Web 模块”。为此,我们需要解锁实用程序模块,然后检查动态 Web 模块。
But , Utility module is also necessary for Java EE Application. So how to select both Utility and Dynamic Web Module to make it Dynamic Web Project so that we can get Run On server Option.
但是,Java EE 应用程序也需要实用程序模块。那么如何同时选择Utility 和Dynamic Web Module 使其成为Dynamic Web Project,以便我们获得Run On server Option。
Note : I have already copied necessary things in .project file and files in .settings folder.
注意:我已经在 .project 文件和 .settings 文件夹中的文件中复制了必要的东西。