Java 将 Maven 项目转换为 Eclipse 的动态 Web 项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18036323/
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-08-11 21:57:09  来源:igfitidea点击:

Converting Maven project to Dynamic Web Project for Eclipse

javaeclipsemaveneclipse-wtpproject-conversion

提问by Vimal Basdeo

  1. Create a web project using Maven:

    mvn archetype:generate -DgroupId=com.trial -DartifactId=message 
       -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
    
  2. Convert the project to Eclipse web project using:

    mvn eclipse:eclipse -Dwtpversion=2.0
    
  3. Import existing project into Eclipse:

  1. 使用 Maven 创建一个 web 项目:

    mvn archetype:generate -DgroupId=com.trial -DartifactId=message 
       -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
    
  2. 使用以下命令将项目转换为 Eclipse Web 项目:

    mvn eclipse:eclipse -Dwtpversion=2.0
    
  3. 将现有项目导入 Eclipse:

enter image description here

在此处输入图片说明

The project icon contains an folder instead of a web icon and folder icon. I find this a bit strange and when I try to run also, the run on server option is missing. I am sure I followed the steps correctly. Where may I be lagging to obtains such a result ?

项目图标包含一个文件夹,而不是 Web 图标和文件夹图标。我觉得这有点奇怪,当我也尝试运行时,缺少在服务器上运行选项。我确定我正确地遵循了这些步骤。我在哪里可能会落后于获得这样的结果?

回答by Roman C

WTP version is rather old, you should add a web project features instead. Edit the .projectfile and write under the naturestag

WTP 版本比较老,你应该添加一个 web 项目功能来代替。编辑.project文件并写在natures标签下

<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>

and under the buildSpectag add builders

并在buildSpec标签下添加建设者

<buildCommand>
    <name>org.eclipse.wst.common.project.facet.core.builder</name>
    <arguments>
    </arguments>
</buildCommand>
<buildCommand>
    <name>org.eclipse.wst.validation.validationbuilder</name>
    <arguments>
    </arguments>
</buildCommand>

回答by Nirdesh Sharma

I have the below's suggestions :

我有以下建议:

  1. First check whether your eclipse is in Jave EE Perspectiveor not. If it was in only Java perspective, run option will not come.

  2. Right click on your project, go to properties.

    Click on Project Facets

    Check whether Dynamic Web moduleis check marked or not. If not just check marked it.

  1. 首先检查您的日食是否在Jave EE Perspective。如果它只是在 Java 视角中,则不会出现运行选项。

  2. 右键单击您的项目,转到属性。

    点击 Project Facets

    检查是否Dynamic Web module被选中。如果不只是检查标记它。