Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 向spark提交具有冲突jackson依赖项的作业?_Json_Scala_Apache Spark_Jackson - Fatal编程技术网

Json 向spark提交具有冲突jackson依赖项的作业?

Json 向spark提交具有冲突jackson依赖项的作业?,json,scala,apache-spark,jackson,Json,Scala,Apache Spark,Jackson,我创建了一个使用jackson 2.7.5的uber jar。我使用的是spark 1.6.2(因为我使用的是scala-2.10)。然而,每当我尝试提交我的spark作业时,我都会发现错误,即在更高版本的jackson中的功能开关上找不到任何方法 我假设uber jar允许我捆绑自己的依赖项,即使它们与spark需要运行的东西冲突,也可以使用某种委托类加载器来隔离冲突。不是这样吗?如果不是,我该如何着手解决这个问题 我知道有这样一个答案,它基本上建议使用sparks jackson而不是您自己

我创建了一个使用jackson 2.7.5的uber jar。我使用的是spark 1.6.2(因为我使用的是scala-2.10)。然而,每当我尝试提交我的spark作业时,我都会发现错误,即在更高版本的jackson中的功能开关上找不到任何方法

我假设uber jar允许我捆绑自己的依赖项,即使它们与spark需要运行的东西冲突,也可以使用某种委托类加载器来隔离冲突。不是这样吗?如果不是,我该如何着手解决这个问题


我知道有这样一个答案,它基本上建议使用sparks jackson而不是您自己的,但是spark的jackson现在已经很旧了,我有依赖于新jackson功能的代码,您需要对依赖项进行着色,以便两个版本可以共存。您的较新版本路径名将被更改以解决冲突

如果您使用的是Maven:

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

  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>

  <groupId><!-- YOUR_GROUP_ID --></groupId>
  <artifactId><!-- YOUR_ARTIFACT_ID --></artifactId>
  <version><!-- YOUR_PACKAGE_VERSION --></version>

  <dependencies>

    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-sql_2.11</artifactId>
      <version><!-- YOUR_SPARK_VERSION --></version>
      <scope>provided</scope>
    </dependency>
    <!-- YOUR_DEPENDENCIES -->
  </dependencies>
  <build>
    <plugins>

      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <scalaVersion><!-- YOUR_SCALA_VERSION --></scalaVersion>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <mainClass><!-- YOUR_APPLICATION_MAIN_CLASS --></mainClass>
                </transformer>
              </transformers>
              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>META-INF/maven/**</exclude>
                    <exclude>META-INF/*.SF</exclude>
                    <exclude>META-INF/*.DSA</exclude>
                    <exclude>META-INF/*.RSA</exclude>
                  </excludes>
                </filter>
              </filters>
              <relocations>
                <relocation>
                  <pattern>com</pattern>
                  <shadedPattern>repackaged.com.google.common</shadedPattern>
                  <includes>
                    <include>com.google.common.**</include>
                  </includes>
                </relocation>
              </relocations>
            </configuration>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>

</project>

4.0.0
1.8
1.8
如果使用
--conf
spark.driver.extraClassPath
spark.executor.extraClassPath
是可能的


请查看我的回答。

我的JAR是否优先于sparks类路径?8.不,那么这不会有什么区别,对吧?它显然是从它自己的类路径中获取jackson,而不是首先让我加载自己的版本。我面临着一个类似的问题,即通过作业服务器引用多个netty版本。你能解决这个问题吗?我最终提取了spark源代码,更新了它们的依赖关系,并创建了一个自定义构建