spark项目借助maven-shade-plugin插件打包依赖

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_40294332/article/details/79850102

maven配置

 <profiles>
        <profile>
            <id>spark-cluster</id>
            <dependencyManagement>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.spark</groupId>
                        <artifactId>spark-core_2.11</artifactId>
                        <version>2.2.1</version>
                        <scope>provided</scope>
                    </dependency>

                    <dependency>
                        <groupId>org.apache.spark</groupId>
                        <artifactId>spark-sql_2.11</artifactId>
                        <version>2.2.1</version>
                        <scope>provided</scope>
                    </dependency>

                    <dependency>
                        <groupId>org.apache.spark</groupId>
                        <artifactId>spark-streaming_2.11</artifactId>
                        <version>2.2.1</version>
                        <scope>provided</scope>
                    </dependency>
                </dependencies>
            </dependencyManagement>

            <build>
                <finalName>${project.name}-${project.version}</finalName>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-shade-plugin</artifactId>
                        <!-- <version>3.1.0</version>-->
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>shade</goal>
                                </goals>
                                <configuration>
                                    <relocations>
                                        <relocation>
                                            <pattern>com.google.protobuf</pattern>
                                            <shadedPattern>shaded.com.google.protobuf</shadedPattern>
                                        </relocation>
                                    </relocations>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

猜你喜欢

转载自blog.csdn.net/weixin_40294332/article/details/79850102