2017-12-09 15 views
0

以下の解決策はSpark not working with pureconfigから取られていますが、これを行うためにはmavenのバージョンが分かりません。 pureconfig 0.8をspark-submitを使ってspark 2.1で動作させようとしましたが、IntelliJ以外でも厄介なException in thread "main" java.lang.NoSuchMethodError: shapeless.Witness$.mkWitness(Ljava/lang/Object;)Lshapeless/Witness;エラーが発生しました。Pureconfigを使ったSpark 2.1 Mavenの回避策

assemblyShadeRules in assembly := Seq(
    ShadeRule.rename("shapeless.**" -> "[email protected]") 
    .inLibrary("com.chuusai" % "shapeless_2.11" % "2.3.2") 
    .inLibrary("com.github.pureconfig" %% "pureconfig" % "0.7.0") 
    .inProject 
) 

Spark with Pureconfig - proper maven shade plugin configurationでも解決策を試したことがありますが、運がまだありません。

uber jarファイルを作成して使用した場合の最終的な設定ですが、Mavenシェーディングの仕組みを完全に理解していないと、名前を変更したjarファイルを別に作成する必要がありません。理想的には私はちょうど作成された依存関係を持つjarファイルを使用して、以下を追加第三のjarを作成しないようにしたい:こんなに遅く答えるため

<plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-shade-plugin</artifactId> 
     <version>3.0.0</version> 
     <executions> 
      <execution> 
       <phase>package</phase> 
       <goals> 
        <goal>shade</goal> 
       </goals> 
      </execution> 
     </executions> 
     <configuration> 
      <createDependencyReducedPom>false</createDependencyReducedPom> 
      <relocations> 
       <relocation> 
        <pattern>shapeless</pattern> 
        <shadedPattern>com.shaded.shapeless</shadedPattern> 
       </relocation> 
      </relocations> 
      <filters> 
       <filter> 
        <artifact>*:*</artifact> 
        <excludes> 
         <exclude>META-INF/*.SF</exclude> 
         <exclude>META-INF/*.DSA</exclude> 
         <exclude>META-INF/*.RSA</exclude> 
        </excludes> 
       </filter> 
      </filters> 
      <finalName>uber-${project.artifactId}-${project.version}</finalName> 
     </configuration> 
    </plugin> 
+0

シェイプレスなパッケージ名で例外が発生した場合は、ソースコードの陰影や内部の依存関係が正しく機能していないことを意味します。 Mavenにシェーディング設定を追加できますか? –

+0

ありがとうございます。私が試した構成を追加するための質問を更新しました。 – horatio1701d

答えて

0

申し訳ありません。 私は実際に何が原因で起こっているのかよく分かりません。私は0.8.0(私は0.7.2を使用していた)に私のpureconfigのバージョンを変更し、すべてがまだ動作するようです。

私のプロジェクトがどのように構造化されているかをより深く理解してもらえます。ああ、btw、私は3.3.9を使用していますが、私はそれが問題だと思っています。

私のプロジェクトはサブモジュールで構成されています。つまり、トップレベルのpomがあり、<modules></modules>が指定されています。すべてのモジュールには独自のpomがあります。

は今、トップレベルのポンポンで、私は依存関係の管理だけでなく、プラグインの管理を使用するので、それは次のようになります。

サブモジュールで今
</dependencyManagement> 
    <dependencies> 
    <dependency> 
     <!-- some dependency --> 
    </dependency> 
    </dependencies> 
</dependencyManagement> 

<build> 
    <pluginManagement> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <version>3.0.0</version> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-shade-plugin</artifactId> 
       <version>3.0.0</version> 
       <executions> 
        <execution> 
         <phase>package</phase> 
         <goals> 
          <goal>shade</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <createDependencyReducedPom>false</createDependencyReducedPom> 
        <relocations> 
         <relocation> 
          <pattern>shapeless</pattern> 
          <shadedPattern>com.matek.chuusai.shapeless</shadedPattern> 
         </relocation> 
        </relocations> 
       </configuration> 
      </plugin> 
     </plugins> 
    </pluginManagement> 
</build> 

、依存関係を設定するだけでなく、Mavenのシェードプラグインを追加します

<dependencies> 
     <dependency> 
      <!-- some dependency --> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <artifactId>maven-shade-plugin</artifactId> 
       <groupId>org.apache.maven.plugins</groupId> 
      </plugin> 
     </plugins> 
    </build> 

プロジェクトにサブモジュールがある場合は、このように設定してください。これが(何らかの形で)助けてくれることを願います。