首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将特定版本的jar包含到Uber jar中?

如何将特定版本的jar包含到Uber jar中?
EN

Stack Overflow用户
提问于 2019-11-11 07:55:56
回答 1查看 147关注 0票数 0

在构建我的项目时,maven下载了依赖项spark-avro,版本为1.8.2和2.4.3,并且它打包了错误的版本。

在我的pom.xml文件中,我只有spark-avro版本2.4.3,1.8.2是来自其他地方的可传递依赖。

如何指定要包含到uber jar中的具体版本?我试着这样做:

代码语言:javascript
复制
<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.4</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <finalName>${project.artifactId}-assembly</finalName>
                        <relocations>
                            <relocation>
                                <pattern>org.apache.http</pattern>
                                <shadedPattern>org.shaded.apache.http</shadedPattern>
                            </relocation>
                        </relocations>
                        <filters>
                            <filter>
                                <artifact>com.alcon.salesforce.etl:alcon-salesforce-etl</artifact>
                                <excludes>
                                    <exclude>com/alcon/etl/glue/common/**</exclude>
                                </excludes>
                            </filter>
                        </filters>
                        <artifactSet>
                            <includes>
this --------------------->   <include>org.apache.avro:spark-avro_2.11:2.4.3</include>
                                <include>com.alcon.etl.common:*</include>
                            </includes>
                        </artifactSet>
                        <shadedArtifactAttached>true</shadedArtifactAttached>
                        <shadedClassifierName>assembly</shadedClassifierName>
                    </configuration>
                </execution>
            </executions>
        </plugin>

正如您在顶部看到的,我在那里编写了spark-avro的特定版本,它是org.apache.avro:spark-avro_2.11:2.4.3,但我在某个地方搞砸了,因为当我提取结果jar的内容时,那里没有spark。

正确的语法是什么?

EN

回答 1

Stack Overflow用户

发布于 2019-11-11 15:45:43

你看错地方了。Maven首先将依赖项合并到一个列表中(在列表中,每个工件只出现在一个版本中)。您的<include>只是此列表中的一个过滤器。

因此,Maven在中介传递依赖关系时可能不会选择您期望的依赖关系。但我不能肯定,因为我没有你的dependency:tree

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58794041

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档