【问题标题】:Maven using local spark libraryMaven 使用本地 spark 库
【发布时间】:2020-01-10 19:35:39
【问题描述】:

由于最近 AWS 上的 EKS 更新,我不再能够在 AWS 上运行 spark 作业(kubernetes 客户端版本必须升级)。 因此,我一直在成功构建最后一个 Spark 快照版本(2.4.5-SNAPSHOT,它包含我需要的错误修复)。 现在我想将它添加到我的项目中,替换旧的 2.3.3 版本。

不幸的是,我遇到了一些编译错误(见下文)。

我的 pom.xml 文件可能有问题。最终目标是从远程和本地(repo)获取 jar 文件

想法? 谢谢!

附: Ubuntu 18.04 + intellij

        The relevant part of the pom.xml file are the following:


        <?xml version="1.0" encoding="UTF-8"?>
        <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/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>


    I add my local repo...

         <!-- My local repo where the jar file has been placed -->
            <repositories>
                <repository>
                    <id>Local</id>
                    <name>Repository Spark</name>
                    <url>/home/cristian/repository/sparkyspark/spark</url>
                </repository>
            </repositories>

        <groupId>sparkjob</groupId>
        <artifactId>sparkjob</artifactId>
        <version>1.0-SNAPSHOT</version>

        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
            <maven.test.skip>true</maven.test.skip>
        </properties>

        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <configuration>
                        <archive>
                            <manifest>
                                <mainClass>entry.Main</mainClass>
                            </manifest>
                        </archive>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                    </configuration>

                    <executions>
                        <execution>
                            <id>make-assembly</id>
                            <!-- bind to the packaging phase -->
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>1.4.1</version>
                    <configuration>
                        <rules><dependencyConvergence/></rules>
                    </configuration>
                </plugin>
            </plugins>
        </build>



        ...

        <dependencies>
        .... 
        ....
    here it is, the jar file I need
         <!-- The last Spark jar file -->
            <dependency>
                <groupId>org.apache.spark</groupId>
                <artifactId>spark-core_2.11</artifactId>
                <version>2.4.5-SNAPSHOT</version>
                <exclusions>
                    <exclusion>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-core</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
        ...
        ....
         </dependencies>

This is the error message, the path is correct...the file is there.
Ideas? :)

错误:

Could not resolve dependencies for project sparkjob:sparkjob:jar:1.0-SNAPSHOT: Failed to collect dependencies at org.apache.spark:spark-core_2.11:jar:2.4.5-SNAPSHOT: Failed to read artifact descriptor for org.apache.spark:spark-core_2.11:jar:2.4.5-SNAPSHOT: Could not transfer artifact org.apache.spark:spark-core_2.11:pom:2.4.5-SNAPSHOT from/to Local (/home/cristian/repository/sparkyspark/spark): Cannot access /home/cristian/repository/sparkyspark/spark with type default using the available connector factories.....

更新:硬接线路径似乎是一个很好的解决方法......

<dependency>
        <groupId>org.apache.spark</groupId>
        <artifactId>spark-core_2.11</artifactId>
        <version>2.4.5-SNAPSHOT</version>
        <scope>system</scope>
        <systemPath>/home/cristian/repository/sparkyspark/spark/spark-core_2.11-2.4.5-SNAPSHOT.jar</systemPath>
        <exclusions>
            <exclusion>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

【问题讨论】:

  • 您是否执行了mvn deploy 将您的 jar 部署到本地存储库?除此之外,您可以定义快照存储库,它将指向您上面提到的文件夹。请注意,您提到的文件夹将遵循存储库结构。 PS:我个人不喜欢在 pom.xml 中指定 systemPath 的方法。如果可能,将这些设置移动到 Maven 配置中。

标签: amazon-web-services maven apache-spark


【解决方案1】:

如果要将文件夹用作存储库,则必须使用file:// 协议。

所以你的存储库配置应该是。

<repositories>
    <repository>
       <id>Local</id>
       <name>Repository Spark</name>
       <url>file:///home/cristian/repository/sparkyspark/spark</url>
    </repository>
</repositories>

【讨论】:

  • 感谢您的回答,不幸的是,我使用 file:/// 或仅使用 file:// 时不断收到相同的错误。无法解析项目 sparkjob:sparkjob:jar:1.0-SNAPSHOT 的依赖关系:未能在 file:///home/cristian/repository/ 中找到 org.apache.spark:spark-core_2.11:jar:2.4.5-SNAPSHOT sparkyspark/火花
  • /home/cristian/repository/sparkyspark/spark 文件夹的内容是什么
  • 我添加了spark maven编译的目标输出:分析original-spark-core_2.11-2.4.5-SNAPSHOT.jar antrun scala-2.11 extra-resources spark-core_2.11-2.4。 5-SNAPSHOT.jar 罐子 spark-core_2.11-2.4.5-SNAPSHOT-sources.jar kubernetes-model-4.4.2.jar spark-core_2.11-2.4.5-SNAPSHOT-tests.jar maven-archiver spark- core_2.11-2.4.5-SNAPSHOT-test-sources.jar maven-shared-archive-resources tmp org
猜你喜欢
  • 2012-06-01
  • 2013-10-11
  • 2019-06-05
  • 1970-01-01
  • 2014-12-22
  • 1970-01-01
  • 2017-06-12
  • 2015-01-06
  • 1970-01-01
相关资源
最近更新 更多