Maven 与 Eclipse

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

Maven vs. Eclipse

javaeclipsemavenproject

提问by Eddy

I have a project written entirely in Java, and using several external Java libraries (hibernate, a couple of Apache commons, MQ, pretty standard stuff.)

我有一个完全用 Java 编写的项目,并使用了几个外部 Java 库(hibernate、几个 Apache commons、MQ、非常标准的东西。)

I'm used to working with Eclipse, but this project -- which I'm inheriting from a group of developers no longer in the company -- is relying on Maven.

我习惯于使用 Eclipse,但是这个项目——我是从一组不再在公司的开发人员那里继承的——依赖于 Maven。

I have no idea why did they use Maven in the first place (they're not available for sharing this knowledge with me.) The project is medium size, and nothing the company is doing is too complex.

我不知道他们为什么首先使用 Maven(他们无法与我分享这些知识。)该项目是中等规模的,公司所做的一切都不是太复杂。

Now my question is: is there any reason for me to keep Maven? Reading around, I can't find any real reason for doing so, and I'm especially unhappy about the directory structure, which requires me to go down 3 levels to get to the actual Java package, and Java code.

现在我的问题是:我有什么理由保留 Maven?环顾四周,我找不到任何这样做的真正原因,而且我对目录结构特别不满意,这需要我向下 3 个级别才能到达实际的 Java 包和 Java 代码。

(What I would like to do is simply move everything to Eclipse, using the Eclipse structure. It's a matter of 1-2 days of work to get it running, so no big loss of time, and from my point of view right now, it will make my life simpler moving forward, and allow me to do a better job for the company that hires me.)

(我想要做的就是使用 Eclipse 结构将所有内容移动到 Eclipse 中。让它运行需要 1-2 天的时间,所以不会浪费太多时间,从我现在的角度来看,这将使我的生活更简单,并让我为雇用我的公司做得更好。)

回答by Dave Newton

Yes: managing transitive dependencies by hand is a fool's errand, and it has a ton of other functionality that is also complicated to do manually.

是的:手动管理可传递的依赖关系是一个傻瓜的差事,它有很多其他功能,手动完成也很复杂。

Relying solely on an IDE's build process is, in general, a Bad Idea. Not everybody uses the same IDE, or version of an IDE, or an IDE at all. Along with the latter, CI systems are headless and rely on build files.

通常,仅依赖 IDE 的构建过程是一个坏主意。并非每个人都使用相同的 IDE,或 IDE 的版本,或根本不使用 IDE。与后者一起,CI 系统是无头的并且依赖于构建文件。

Use an Eclipse-Maven plugin like m2eclipseor similar.

使用 Eclipse-Maven 插件,如m2eclipse或类似插件。

回答by Roman C

Maven is a powerful, extendable, open source project builder. The configuration is contained in the XML files, so it's easily accessible by the any text editor. If you want to share the configuration what you will do is just post the pom.xml. Many IDEs have converters of the project configuration to Eclipse and from Eclipse but this configuration is local and used internally by the development environment. Developers even not save such configuration in the VCS. Checking out such configuration has no sense. But maven is independent because it relies on external repositories that keep track of every library and version used by the project. Many IDEs including Eclipse have Maven support via plugins. That can keep intact both configurations.

Maven 是一个强大的、可扩展的、开源的项目构建器。配置包含在 XML 文件中,因此任何文本编辑器都可以轻松访问它。如果您想共享配置,您只需将pom.xml. 许多 IDE 都有项目配置到 Eclipse 和从 Eclipse 的转换器,但这种配置是本地的,由开发环境在内部使用。开发人员甚至不会在 VCS 中保存此类配置。检查这样的配置是没有意义的。但是 maven 是独立的,因为它依赖于跟踪项目使用的每个库和版本的外部存储库。包括 Eclipse 在内的许多 IDE 都通过插件提供了 Maven 支持。这可以保持完整的两种配置。

回答by Sach

Using maven you don't have to care about importing jars in project as it is mentioned in pom file. Also those jar will be downloaded from maven repository if they are needed(It should present on maven repository). It will also help you to make a all jars in one go(Need to configure only once) :)

使用 maven,您不必关心在项目中导入 jars,因为它在 pom 文件中提到。如果需要,这些 jar 也会从 maven 存储库下载(它应该出现在 maven 存储库中)。它还可以帮助您一次性制作所有罐子(只需配置一次):)

回答by ATOzTOA

You should keep the Maven in place, if you want to use Eclipse, you can do that, and still have Maven fully functional. You can have any folder structure you want in Maven, just need to specify the paths in the pomfile.

您应该保留 Maven,如果您想使用 Eclipse,您可以这样做,并且 Maven 仍然具有完整的功能。你可以在 Maven 中拥有任何你想要的文件夹结构,只需要在pom文件中指定路径。