【问题标题】:is there difference between dependencies and dependencies in plugin tags?插件标签中的依赖项和依赖项之间有区别吗?
【发布时间】:2013-04-10 05:04:56
【问题描述】:

我有一个问题。

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

我认为标签中的依赖关系只是与插件有关吗? 对吗?

提前感谢:)

<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>

【问题讨论】:

标签: maven maven-plugin


【解决方案1】:

&lt;project&gt; 下的&lt;dependencies&gt; 是我们的工件的依赖项列表,Maven 将在编译时为我们下载并链接依赖项。请参阅POM Reference: DependenciesIntroduction to the Dependency Mechanism 了解更多信息。

&lt;plugin&gt; 下的&lt;dependencies&gt; 将作为它们所在插件的依赖项应用。 它的强大之处在于改变插件的依赖列表,可能是通过exclusions删除一个未使用的运行时依赖,或者通过更改所需依赖项的版本。请参阅POM Reference: PluginsGuide to Configuring Plug-ins 了解更多信息。

我希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2020-07-27
    • 2016-12-19
    • 2020-04-26
    • 2018-10-20
    • 2020-08-31
    • 1970-01-01
    • 2015-11-11
    • 2012-08-06
    • 1970-01-01
    相关资源
    最近更新 更多