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

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

问题描述

我在 Grails 中使用 Neo4j 和 MongoDB,我想知道 Maven Neo4j 插件是否也为我的构建提供 Neo4j 依赖项.MongoDB 也是如此.

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 是项目需要在某个时间点(即在编译时或运行时)在其类路径中可用的工件(即 jar)

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)

然而,插件是一个工件,您可以在项目中对其进行配置,以使其在项目构建期间实际执行某些操作.(例如,有一些插件可以实际编译您的 Java 类、复制文件或启动和停止数据库等).您的项目的类路径中没有可用的插件.

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.

以 Neo4J 为例,如果您的项目需要在类路径上提供 Neo4j 类,您可以将其作为依赖项包含 - 可能是因为您正在针对它们的 API 进行编译.但是,如果您只需要一个 Neo4J 服务器来运行您的测试,那么您可以使用 Neo4J 插件 让它在 Maven 运行您的测试之前启动一个服务器,然后该插件将在测试结束后停止服务器测试已完成.

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.

我建议您阅读 Sonatype 的书 Maven: A Complete Reference 了解有关 Maven 的更多详细信息.

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天全站免登陆