Eclipse 和 Maven 通过命令行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12913218/
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
Eclipse and Maven via command line
提问by Codey McCodeface
I can create a simple Maven application in the Eclipse IDE (version 3.71) by skipping archetype selection that contains folders (Edit 2as well as other folders):
我可以通过跳过包含文件夹(Edit 2以及其他文件夹)的原型选择,在 Eclipse IDE(3.71 版)中创建一个简单的 Maven 应用程序:
src/main/resources
src/test/resources
These folders are missing if I use the command line. I have been using the maven guide to create a maven project for my eclipse IDE using the command line as specified on the Maven site
如果我使用命令行,这些文件夹将丢失。我一直在使用 Maven 指南使用Maven 站点上指定的命令行为我的 Eclipse IDE 创建一个 Maven 项目
mvn archetype:generate -DgroupId=guide.ide.eclipse -DartifactId=guide-ide-eclipse
How do I mimic Eclipse's behaviour via the command line? I have tried to find the correct archetypeID and add the arguments to no success.
如何通过命令行模仿 Eclipse 的行为?我试图找到正确的 archetypeID 并添加参数但没有成功。
Edit1
编辑1
The resulting maven project is contained in a git repository so I can import the project as detailed in this question
生成的 maven 项目包含在 git 存储库中,因此我可以按照此问题中的详细说明导入该项目
回答by KItis
This inconsistency problem is long identified with the Eclipse plugin for Maven.If you use the Eclipse IDE for executing Maven commands, It will not work exactly the way that Maven works with command line. So what most developers do is, run the maven commands from command line and then execute
长期以来,Maven 的 Eclipse 插件都会发现这种不一致问题。如果您使用 Eclipse IDE 来执行 Maven 命令,它的工作方式将与 Maven 使用命令行的方式完全不同。所以大多数开发人员所做的是,从命令行运行 maven 命令,然后执行
mvn eclipse:eclipse
mvn eclipse:eclipse
to update eclipse project. After that you go back to Eclipse IDE and refresh your project. then your project will be updated as per the changes done via command line.
更新eclipse项目。之后,您将返回 Eclipse IDE 并刷新您的项目。那么您的项目将根据通过命令行所做的更改进行更新。
It is also recommended to update your pom.xml with following configuration:
还建议使用以下配置更新您的 pom.xml:
<plugin>
<version>2.9</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>