gpt4 book ai didi

maven - Maven Shade-更改文件名并替换文本

转载 作者:行者123 更新时间:2023-12-02 22:50:43 29 4
gpt4 key购买 nike

我试图使用Maven Shade并包装ElasticSearch jar。

之所以这样做,是因为我的项目中Lucene版本之间存在冲突。

但是当我使用Shade时发现了问题。它不会更改META-INF/services中的文件名,也不会更改该特定文件中的FQN。

我需要更改org.apache.lucene.codecs.Codec文件及其内容。因为如果此文件保留其名称,那么我会报错"Caused by: java.lang.IllegalArgumentException: An SPI class of type shaded_lucene_4_10_4.org.apache.lucene.codecs.Codec with name 'Lucene410' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath. The current classpath supports the following names: []"
是否可以使用Maven Shade插件包装ElasticSearch?

Here is my pom.xml

最佳答案

是的,有可能,只需要添加ServicesResourceTransformer条目。
像这样:

  <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.myorg.esclient.App</mainClass>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin>

检查:
http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#ServicesResourceTransformer

关于maven - Maven Shade-更改文件名并替换文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31586697/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com