Submitting spring boot application jar to spark-submit

前端 未结 4 1775
野的像风
野的像风 2021-02-08 17:58

I am pretty new to spark, and i am trying to try out spark submit. I created an application in spring boot , used mvn package to create a jar . But when i am trying

相关标签:
4条回答
  • 2021-02-08 18:17

    We ran into the same problem, actually, on the same day you posted this. Our solutions was to use the shade plugin for maven to edit our build a bit. We found that when packaging with the spring-boot-maven plugin it nested our classes in BOOT-INF/classes which spark didn't like. I'll paste the relevant section so you can try it out on your own application -- good luck!

    <build>
       <plugins>
          <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                        <version>${spring-boot-version}</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
                    <createDependencyReducedPom>false</createDependencyReducedPom>
                    <filters>
                        <filter>
                            <artifact>*:*</artifact>
                            <excludes>
                                <exclude>META-INF/*.SF</exclude>
                                <exclude>META-INF/*.DSA</exclude>
                                <exclude>META-INF/*.RSA</exclude>
                            </excludes>
                        </filter>
                    </filters>
                    <transformers>
                        <transformer
                                implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                            <resource>META-INF/spring.handlers</resource>
                        </transformer>
                        <transformer
                                implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
                            <resource>META-INF/spring.factories</resource>
                        </transformer>
                        <transformer
                                implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                            <resource>META-INF/spring.schemas</resource>
                        </transformer>
                        <transformer
                                implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                        <transformer
                                implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                            <mainClass>${start-class}</mainClass>
                        </transformer>
                    </transformers>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    
    0 讨论(0)
  • 2021-02-08 18:18

    If your are using gradle this will work for shadow plugin:

    import com.github.jengelman.gradle.plugins.shadow.transformers.*
    
    ...
    
    plugins {
        id 'com.github.johnrengelman.shadow' version '2.0.4'
    }
    
    ...
    
    shadowJar {
        zip64 true
        mergeServiceFiles()
        append 'META-INF/spring.handlers'
        append 'META-INF/spring.schemas'
        append 'META-INF/spring.tooling'
        transform(PropertiesFileTransformer) {
            paths = ['META-INF/spring.factories' ]
            mergeStrategy = "append"
        }
    }
    

    Taken from here: https://github.com/spring-projects/spring-boot/issues/1828#issuecomment-607352468

    0 讨论(0)
  • 2021-02-08 18:25

    I have found that simply skipping the class name from spark-submit works, i.e. --class com.dip.sparkapp.SparkappApplication

    0 讨论(0)
  • 2021-02-08 18:26

    This works for me

    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
        <manifestEntries>
            <Main-Class>packagename.classname</Main-Class>
        </manifestEntries>
    </transformer>
    
    0 讨论(0)
提交回复
热议问题