如果我使用 Eclipse,为什么我需要 Maven?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5037798/
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
Why do I need Maven if I use Eclipse?
提问by Nishant
I have seen that if I right click on a project in Eclipse and choose to run it on a server, then I can see output which means the project is running.
我已经看到,如果我在 Eclipse 中右键单击一个项目并选择在服务器上运行它,那么我可以看到输出,这意味着该项目正在运行。
If everything is working fine without Maven, what's the point of using it. How is it different than simply running it via eclipse?
如果在没有 Maven 的情况下一切正常,那么使用它有什么意义。它与简单地通过 eclipse 运行它有什么不同?
回答by Nishant
Maven is a build tool (build manager, in fact), similar to ANT. The main job of any build tool is configure the project, compile using required projects and do the final packaging. A build script in your project gives a blue-print of project's deliverable structure. This frees you from any configurable dependencies on specific IDE like Eclipse. All you need to know is the standard command to perform the build and you can build your code almost anywhere.
Maven 是一个构建工具(实际上是构建管理器),类似于 ANT。任何构建工具的主要工作是配置项目、使用所需项目进行编译并进行最终打包。项目中的构建脚本提供了项目可交付结构的蓝图。这使您免于对特定 IDE(如 Eclipse)的任何可配置依赖项。您需要知道的是执行构建的标准命令,您几乎可以在任何地方构建代码。
Now, back to your question, why wouldn't do it in Eclipse?
现在,回到您的问题,为什么不在 Eclipse 中执行此操作?
For a simple project and small team Maven is an overkill. You can easily communicate the configuration, IDE to use, and instruct any special steps to be taken. In big projects, however, there exits lots of loosely coupleddependencies. To start with, there will be different settings for developer machine build, test build and production build. There are requirements to run automated test, integration tests, store the build package (artifact) to a commonly accessible repository, update versions of various modules.
对于一个简单的项目和小团队来说,Maven 是一种矫枉过正。您可以轻松地传达配置、要使用的 IDE,并指示要采取的任何特殊步骤。然而,在大型项目中,存在许多松散耦合的依赖项。首先,开发人员机器构建、测试构建和生产构建将有不同的设置。需要运行自动化测试、集成测试、将构建包(工件)存储到可普遍访问的存储库、更新各种模块的版本。
Obviously, if all the steps mentioned above is done manually there are chances of missing a step. Moreover, the manual process is time consuming.
显然,如果上述所有步骤都是手动完成的,则可能会遗漏一个步骤。此外,手动过程是耗时的。
Ideally, you should prefer a tool which fits the best for you. If you think that you're able to achieve what you required without Maven, it makes sense to not to use Maven/build-tool just because everyone uses it.
理想情况下,您应该更喜欢最适合您的工具。如果您认为无需 Maven 即可实现所需的功能,那么不要仅仅因为每个人都使用 Maven/build-tool 就使用它是有意义的。
It is suggested to study automated deployment, this will give you bigger picture on what all the stuffs that you can do with build tools. And if you do not feel that it adds any value to your current process, you probably don't need Maven or any other build tool right now.
建议研究自动化部署,这将使您更全面地了解您可以使用构建工具做什么。如果您认为它不会为您当前的流程增加任何价值,那么您现在可能不需要 Maven 或任何其他构建工具。
回答by CoolBeans
Your question does not make much sense. Do you expect your users to access your application from eclipse? If so that is a very strange set up in my opinion.
你的问题没有多大意义。您希望您的用户从 eclipse 访问您的应用程序吗?如果是这样,我认为这是一个非常奇怪的设置。
Perhaps your question should be about how to build your project. Maven provides you a way to centralize dependency libraries across the enterprise. It lets you automate your build process (most likely in conjunction with a CI server like hudson, cruise control, etc). It lets you automate your unit testing. Maven makes the packaging of app very easy to do. A developer does not have to follow arcane set of steps to package an application. You add the right plugin and maven takes care of it as part of the build life cycle. All of this magic can happen because of the principle of convention over configuration. There are many more benefits, I just named a few.
也许您的问题应该是关于如何构建您的项目。Maven 为您提供了一种在整个企业范围内集中依赖库的方法。它可以让您自动化构建过程(最有可能与像 hudson、巡航控制等的 CI 服务器结合使用)。它可以让你自动化你的单元测试。Maven 使应用程序的打包变得非常容易。开发人员不必遵循一组晦涩难懂的步骤来打包应用程序。您添加了正确的插件,maven 会将其作为构建生命周期的一部分进行处理。由于约定优于配置的原则,所有这些魔法都可能发生。还有很多好处,我只是列举了几个。
Maven is not replacing how you run the app, rather how you packagethe app, automate that process, and manage the dependencies of your app.
Maven 不会取代您运行应用程序的方式,而是您打包应用程序、自动化该过程以及管理应用程序依赖项的方式。
Some links on why someone should use maven:-
关于为什么有人应该使用 maven 的一些链接:-