插件标签中的依赖项和依赖项之间有区别吗? [英] is there difference between dependencies and dependencies in plugin tags?

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

问题描述

我有一个问题.

在pom.xml中,依赖关系包含在两个位置. 一个地方可以在<project>标签中,而另一个地方可以在<plugin>标签中.

In pom.xml, dependency is included in two places. one place can be in <project> tag and the other place can be in <plugin> tag.

我认为标签中的依赖项仅与插件有关? 正确吗?

I think the dependencies in tags is just related with the plugin? is it correct?

提前感谢:)

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <artifactId>clustered-queue</artifactId>
   <packaging>jar</packaging>
   <name>HornetQ JMS Clustered Queue Example</name>

   <dependencies>

      <dependency>
         <groupId>org.hornetq.examples.jms</groupId>
         <artifactId>hornetq-jms-examples-common</artifactId>
         <version>${project.version}</version>
      </dependency>
      <dependency>
         <groupId>org.jboss.spec.javax.jms</groupId>
         <artifactId>jboss-jms-api_1.1_spec</artifactId>
      </dependency>

   </dependencies>

   <build>
      <plugins>
         <plugin>
            <groupId>org.hornetq</groupId>
            <artifactId>hornetq-maven-plugin</artifactId>
            <executions>
               <execution>
                  <id>start1</id>
                  <goals>
                     <goal>start</goal>
                  </goals>
                  <configuration>
                     <jndiPort>1199</jndiPort>
                     <jndiRmiPort>1198</jndiRmiPort>
                     <hornetqConfigurationDir>${basedir}/target/classes/hornetq/server1</hornetqConfigurationDir>
                     <fork>true</fork>
                     <systemProperties>
                        <property>
                           <name>udp-address</name>
                           <value>${udp-address}</value>
                        </property>
                     </systemProperties>
                  </configuration>
               </execution>
            </executions>
            <dependencies>

               <dependency>
                  <groupId>org.hornetq</groupId>
                  <artifactId>hornetq-core-client</artifactId>
                  <version>${project.version}</version>
               </dependency>
               <dependency>
                  <groupId>org.hornetq</groupId>
                  <artifactId>hornetq-server</artifactId>
                  <version>${project.version}</version>
               </dependency>

            </dependencies>
            <configuration>
               <waitOnStart>false</waitOnStart>
            </configuration>
         </plugin>
      </plugins>
   </build>

</project>

推荐答案

<project>下的<dependencies>是我们工件的依赖项列表,Maven将在编译时下载并链接我们的依赖项.请参阅 POM参考:依赖性

The <dependencies> which is under the <project> is a dependency list for our artifacts which Maven will download and link the dependencies for us on compilation. Please see POM Reference: Dependencies and Introduction to the Dependency Mechanism for further information.

<plugin>下的<dependencies>将作为其所在插件的依赖项来应用. 此功能的用途是更改插件的依赖项列表 ,可能是通过通过exclusions删除未使用的运行时依赖项,或通过更改所需依赖项的版本.请参阅 POM参考:插件

The <dependencies> which is under the <plugin> is to apply as dependencies of the plugin that they are under. The power of this is to alter the dependency list of a plugin, perhaps by removing an unused runtime dependency via exclusions, or by altering the version of a required dependency. Please see POM Reference: Plugins and Guide to Configuring Plug-ins for further information.

我希望这会有所帮助.

这篇关于插件标签中的依赖项和依赖项之间有区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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