Eclipse 中的“自动构建”和 Maven
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18283429/
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
the "build automatically" and maven in Eclipse
提问by lovespring
in Eclipse, when Maven is enabled, there is a pom.xml file to build with Maven. And also, Eclipse has a "build automatically" option in it's project menu.
在 Eclipse 中,当启用 Maven 时,有一个 pom.xml 文件可以用 Maven 构建。而且,Eclipse 在它的项目菜单中有一个“自动构建”选项。
Is the "build automatically" automatically build with Maven, or we need uncheck it, because when Maven is enabled, we don't need the Eclipse build in build system anymore?
“自动构建”是使用 Maven 自动构建的,还是我们需要取消选中它,因为启用 Maven 后,我们不再需要构建系统中的 Eclipse 构建?
回答by miko?ak
Eclipse's m2ewill run the plugin goals it has lifecycle bindings for. I don't know (and I'm unable to find) what specific phases are run, but from experience I know that:
Eclipse 的m2e将运行它具有生命周期绑定的插件目标。我不知道(也找不到)运行了哪些特定阶段,但根据经验,我知道:
- for normal operation, at least compilegets executed.
- for executing tests (e.g. JUnit test cases), at least test-compilegets executed.
- 对于正常操作,至少compile被执行。
- 为了执行测试(例如 JUnit 测试用例),至少会执行test-compile。
Note that it doesn't have all possible bindings, and going around that problemis sometimes problematic. So, usually, having both should run fine, and in fact will avoid some incongruities due to the compiled state not updating while you code.
请注意,它没有所有可能的绑定,解决这个问题有时是有问题的。因此,通常情况下,两者都应该运行良好,并且实际上会避免由于编译状态在您编码时未更新而导致的一些不协调。
Howeverif you have plugins that are ignored by m2e, you should actually shut down "Build Automatically" offwhen you need to be certainyour build completes correctly.
但是,如果您有被 m2e 忽略的插件,当您需要确保构建正确完成时,您实际上应该关闭“自动构建”。
For example, using the Maven Properties plugin, if you have not provided a binding and set m2e
to ignore, you will have resources with out-of-whack property values. The problem can especially occur when you do a "Maven" build (from the right-click context menu for example), and then do a change in your code and save it.
例如,使用Maven 属性插件,如果您没有提供绑定并设置m2e
为忽略,您将拥有具有不正常属性值的资源。当您执行“Maven”构建(例如,从右键单击上下文菜单),然后对代码进行更改并保存时,尤其会出现该问题。
回答by Eugene Ryzhikov
You need both.Here is why:
你需要两者。原因如下:
Eclipse built-in compiler is used for incremental compilation - when you save your code, for example. But full build of the project is done using maven and project configuration in pom.xml.
Eclipse 内置编译器用于增量编译 - 例如,当您保存代码时。但是项目的完整构建是使用 maven 和 pom.xml 中的项目配置完成的。