简体   繁体   English

使用eclipse / netbeans时,可以使用Maven进行构建吗?

[英]when using eclipse/netbeans, can you make it use the maven to build?

Confused as to building a java spring/mvc web app. 对于构建Java spring / mvc Web应用程序感到困惑。

When you use netbeans or eclipse, do you have to use the maven/ant build script? 当您使用Netbeans或Eclipse时,是否必须使用Maven / ant构建脚本?

if you don't use maven/ant, how does netbeans/eclipse perform the build then? 如果您不使用Maven / ant,那么netbeans / eclipse如何执行构建?

Netbeans has built in support for Maven which is very good. Netbeans内置了对Maven的支持,这非常好。 Netbeans' controls are mapped to maven lifecycle commands. Netbeans的控件映射到maven生命周期命令。

Eclipse has the m2Eclipse plugin. Eclipse具有m2Eclipse插件。 I only used this plugin briefly, but found it lacking. 我只短暂使用了此插件,但发现缺少它。 In my opinion Netbeans has far superior support for Maven. 在我看来,Netbeans对Maven的支持远胜于此。

Edit: to clarify, when you click the netbeans green arrow (for building), that button is mapped to the maven package lifecycle, so at that point maven takes over and builds your project. 编辑:澄清一下,当您单击netbeans绿色箭头(用于构建)时,该按钮将映射到maven软件包生命周期,因此在这一点上maven接管并构建了您的项目。 You could just as easily open a terminal and run mvn package to get the same results. 您可以轻松地打开一个终端并运行mvn package来获得相同的结果。

I can only speak for Eclipse. 我只能代表Eclipse。 In Eclipse, if you create your project as a "Dynamic Web Project", and put things in the relevant places (ie code goes in the src folder, web content including WEB-INF goes in the WebContent folder and so on), Eclipse will automatically build your project. 在Eclipse中,如果您将项目创建为“动态Web项目”,并将其放置在相关位置(例如,代码放在src文件夹中,包括WEB-INF的Web内容放在WebContent文件夹中,依此类推),则Eclipse将自动构建您的项目。

However, if you want to build a WAR file to run outside your local testing environment, the only way I know to do that from within Eclipse is to go to Project -> Export and export it manually. 但是,如果您想构建一个WAR文件以在本地测试环境之外运行,那么我知道在Eclipse中执行此操作的唯一方法是转到Project-> Export并手动将其导出。 If you want to build that automatically, you'll need Ant or Maven. 如果要自动构建,则需要Ant或Maven。

Which is not to say you can't use Ant or Maven within Eclipse: both are fully supported by plugins. 这并不是说您不能 Eclipse中使用Ant或Maven:两者都完全受插件支持。

I use the m2eclipse plugin in Eclipse for handling automatic dependency resolution, but the actual build (within Eclipse) is performed just by compiling any classes on the source path. 我使用Eclipse中的m2eclipse插件来处理自动依赖项解析,但是实际构建(在Eclipse中)仅通过编译源路径上的任何类来执行。

I only use Eclipse to handle compiling my classes and prefer to handle "making a build" (ie packaging, etc) from the command line. 我只使用Eclipse处理类的编译,而更喜欢从命令行处理“构建”(即打包等)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM