Maven在eclipse中使用m2Eclipse查询
我在 Eclipse 中使用 Maven 和 m2Eclipse 插件。
我对如何在 Eclipse 中构建它感到非常困惑。
即时编译正常工作(即就像没有 Maven 一样),因此如果出现错误,它将突出显示。
但是,例如,当我想运行 junit 时,只有在运行 Maven 构建命令后才会拾取对代码的任何更改。 Eclipse 项目 clean 似乎不起作用。
任何帮助解释这一切应该如何工作的帮助将不胜感激。
I'm using Maven in Eclipse with the m2Eclipse plugin.
I'm very confused about how this is supposed to build within eclipse.
The on-the-fly compiling works as normal (i.e. as if without maven) so if you have an error it will be highlighted.
But when I want to run a junit for example, any changes to the code are only picked up after I run a maven build command. The Eclipse project clean doesn't seem to work.
Any help in explaining how this is all supposed to work would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
eclipse 构建器使用比 maven 更简单的逻辑,因此有时 m2eclipse 所做的事情还不够。在运行单元测试之前,我通常保持 shell 打开以发出简单的命令。根据您的设置,这里有一些可能有用的命令。
如果您知道唯一需要的资源处理是maven资源过滤,只需调用目标:
测试相同:
或者
如果您需要更完整的解决方案,因为可能需要生成一些新代码等,那么使用
所以您会变得漂亮除了实际的单元测试执行之外的一切。大多数插件都足够智能,可以检测更改并保留未更改的文件,因此 mvn
test-compile
通常足够快。如果您不想使用 shell,您当然可以将上述任何阶段/目标绑定到 m2eclipse
Run as... maven build
目标。The eclipse builder uses simpler logic than maven, so sometimes the things m2eclipse does are just not enough. I usually keep a shell open to issue simple commands before I run unit tests. depending on your setup, here are some commands that might be helpful.
If you know that the only resource processing needed is maven resource filtering, just call the goal:
Same for tests:
or
If you need a fuller solution, because perhaps some new code has to be generated etc, then use
So you're getting pretty much everything except the actual unit test execution. Most plugins are smart enough to detect changes and leave unchanged files alone, so mvn
test-compile
is usually fast enough.If you prefer not to use a shell, you can of course bind any of the above phases / goals to m2eclipse
Run as... maven build
targets.查看 http://m2eclipse.sonatype.org/ 插件文档和指南。
Checkout the http://m2eclipse.sonatype.org/ plugin documentation and guide.