Maven插件和依赖关系有什么区别? [英] What's the difference between Maven plugins and dependencies?

查看:361
本文介绍了Maven插件和依赖关系有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Neo4j和MongoDB与Grails,我想知道Maven Neo4j插件是否还提供Neo4j依赖关系到我的构建。对于MongoDB也是如此。



我很困惑。我应该用什么,插件或依赖?有什么区别?

解决方案

依赖关系是您的项目需要在某个时间点的类路径中可用的工件(即jar)(即在编译时)时间或运行时间)



然而,插件是一个工件,您可以在项目中进行配置,使其在项目构建期间实际执行某些操作。 (所以例如有一些插件来实际编译你的java类,复制文件或者在其他许多数据库之间启动和停止数据库)。一个插件不可用在您的项目的类路径上。



以Neo4J为例,如果您的项目需要neo4j类可以在类路径中使用 - 也许是因为您正在编译它们的API。然而,如果您只需要运行Neo4J服务器进行测试,那么在Maven运行测试之前,您将使用Neo4J 插件启动服务器,然后插件会在服务器之后停止测试已经完成。



我建议您阅读Sonatype的书籍 Maven:一个完整​​的参考,了解更多有关Maven的详细信息。


I am using Neo4j and MongoDB with Grails, and I want to know whether the Maven Neo4j plugin also provides the Neo4j dependencies to my build. Similarly for MongoDB.

I am confused. What should I used, plugins or dependencies? What is the difference?

解决方案

Dependencies are artifacts (i.e. a jar) that your project requires to be available in its classpath at some point in time (i.e. at compile time or runtime)

A plugin however is an artifact that you can configure in your project to have it actually do something during the build of your project. (so for example there are plugins to actually compile your java classes, to copy files or to start and stop a database among many others). A plugin is not available on your project's classpath.

Taking Neo4J as an example, you would include it as a dependency if your project requires the neo4j classes to be available on the classpath - maybe because you are compiling against their API. If however you simply need a Neo4J server to be running for your tests, then you would use the Neo4J plugin to have it start a server before Maven runs your tests and then the plugin would stop the server after the tests have completed.

I would recommend taking a read of Sonatype's book Maven: A Complete Reference for more details on Maven in general.

这篇关于Maven插件和依赖关系有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆