如何从Maven插件更改默认依赖关系



我在项目中使用Maven依赖性 - plugin,该项目依赖于支柱1.3.8。由于某些安全问题,我的公司不允许下载Struts 1.3.8。如何将其更改为不同的版本。

请查看https://maven.apache.org/plugins/maven-depparency-plugin/usage.html,并特别在以下部分中:

...
    <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>[ groupId ]</groupId>
                  <artifactId>[ artifactId ]</artifactId>
                  <version>[ version ]</version>
                  <type>[ packaging ]</type>
                  <classifier> [classifier - optional] </classifier>
                  <overWrite>[ true or false ]</overWrite>
                  <outputDirectory>[ output directory ]</outputDirectory>
                  <destFileName>[ filename ]</destFileName>
                </artifactItem>
              </artifactItems>
              <!-- other configurations here -->
    </configuration>
...

在[版本]中,您应该能够设置适当的版本。您还需要设置[groupId],[artifactid]等域等,但是我认为您已经做到了,只需要[版本]元素或我错了?但是,如果我可能会问:为什么需要插件?依赖性类似:

       <dependency>
           <groupId>your.atrifact.group.id</groupId>
           <artifactId>artifactID</artifactId>
           <version>your_version</version>
       </dependency>

不为您服务?

您始终可以定义插件的依赖性:

  • 以任何方式更改支柱的groupid/artifactid。
  • 更改优秀的支柱的版本。我使用了一个版本范围,该范围应忽略1.3.8版。
<plugin>
  <artifactId>maven-dependency-plugin</artifactId>
  <version>...</version>
  <dependencies>
    <dependency>
      <groupId>struts</groupId> 
      <artifactId>struts</artifactId>
      <version>[1.3,1.3.8)</version>
    <dependency>
  </dependencies>
</plugin>

最新更新