在pom xml中的依赖关系和插件标签之间的maven有什么区别? [英] What is the difference in maven between dependency and plugin tags in pom xml?
问题描述
插件和依赖都是Jar文件。
但是它们之间的区别是,maven中的大部分工作都是使用插件完成的;而依赖关系只是一个Jar文件,它将在执行任务时添加到类路径中。
例如,您使用编译器插件来编译java文件。您不能使用compiler-plugin作为依赖关系,因为它只会将插件添加到类路径中,并且不会触发任何编译。要在编译文件时添加到类路径中的Jar文件将被指定为依赖关系。
与您的方案相同。你必须使用spring-plugin来执行一些spring的可执行文件[我不知道用什么spring-plugins。我只是在这里猜测]。但是您需要依赖来执行这些可执行文件。并且Junit被标记为依赖,因为它由surefire-plugin用于执行单元测试。
所以,我们可以说,plugin是一个执行任务的Jar文件,依赖是一个提供类文件来执行任务的Jar。
希望能回答您的问题!
I'm new to the maven tool, I have made a project with Spring and Hibernate and they are configured in pom.xml as plugins, but JUnit is tagged under dependency. My question is what is the logic behind one as a plugin and one as dependency ?
Both plugins and dependencies are Jar files.
But the difference between them is, most of the work in maven is done using plugins; whereas dependency is just a Jar file which will be added to the classpath while executing the tasks.
For example, you use a compiler-plugin to compile the java files. You can't use compiler-plugin as a dependency since that will only add the plugin to the classpath, and will not trigger any compilation. The Jar files to be added to the classpath while compiling the file, will be specified as a dependency.
Same goes with your scenario. You have to use spring-plugin to execute some spring executables [ I'm not sure what spring-plugins are used for. I'm just taking a guess here ]. But you need dependencies to execute those executables. And Junit is tagged under dependency since it is used by surefire-plugin for executing unit-tests.
So, we can say, plugin is a Jar file which executes the task, and dependency is a Jar which provides the class files to execute the task.
Hope that answers your question!
这篇关于在pom xml中的依赖关系和插件标签之间的maven有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!