• scala spark maven打包记录



    4.0.0

    <groupId>com.first</groupId>
    <artifactId>one-dream</artifactId>
    <version>1.0-SNAPSHOT</version>
    
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <spark.version>2.4.0</spark.version>
        <scala.version>2.11</scala.version>
        <hadoop.version>2.7.3</hadoop.version>
        <cdh.version>6.3.1</cdh.version>
        <slf4j.version>1.7.25</slf4j.version>
        <log4j.version>2.8.2</log4j.version>
        <jedis.version>3.2.0</jedis.version>
        <redis.version>2.4.0</redis.version>
        <java.version>1.8</java.version>
        <maven.compiler.source.version>1.8</maven.compiler.source.version>
        <maven.compiler.target.version>1.8</maven.compiler.target.version>
        <maven.java.version>3.2</maven.java.version>
        <maven.scala.version>3.2.2</maven.scala.version>
        <maven.package.version>2.4.3</maven.package.version>
        <one-dream.version>1.0</one-dream.version>
    </properties>
    
    <dependencies>
    
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-common</artifactId>
            <version>${hadoop.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-mapreduce-client-core</artifactId>
            <version>${hadoop.version}</version>
        </dependency>
    
        <!--spark related-->
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_${scala.version}</artifactId>
            <version>${spark.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-streaming_${scala.version}</artifactId>
            <version>${spark.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-sql_${scala.version}</artifactId>
            <version>${spark.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-hive_${scala.version}</artifactId>
            <version>${spark.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-mllib_${scala.version}</artifactId>
            <version>${spark.version}</version>
        </dependency>
    
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-mllib_${scala.version}</artifactId>
            <version>${spark.version}</version>
        </dependency>
    
        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.11</version>
        </dependency>
    
    
        <!-- 根据examples报错信息,进行导入 -->
        <dependency>
            <groupId>com.github.scopt</groupId>
            <artifactId>scopt_2.11</artifactId>
            <version>3.7.1</version>
        </dependency>
    
        <!-- https://mvnrepository.com/artifact/org.apache.spark/spark-streaming-kafka -->
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-streaming-kafka-0-10_${scala.version}</artifactId>
            <version>${spark.version}</version>
        </dependency>
    
        <dependency>
            <groupId>com.redislabs</groupId>
            <artifactId>spark-redis</artifactId>
            <version>${redis.version}</version>
        </dependency>
    
        <!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>${jedis.version}</version>
        </dependency>
    
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.34</version>
        </dependency>
    
    </dependencies>
    
    <build>
        <!--<finalName>one-dream_${one-dream.version}</finalName>-->
        <!-- 把所有的源码包打在一起
           <resources>
    
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
        </resources>
    
        &lt;!&ndash; 声明插件 &ndash;&gt;
        <pluginManagement>
            <plugins>
                &lt;!&ndash; 编译scala的插件 &ndash;&gt;
                <plugin>
                    <groupId>net.alchim31.maven</groupId>
                    <artifactId>scala-maven-plugin</artifactId>
                    <version>${maven.scala.version}</version>
                </plugin>
                &lt;!&ndash;编译java的插件,指定jdk版本&ndash;&gt;
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven.java.version}</version>
                    <configuration>
                        <source>${java.version}</source>
                        <target>${java.version}</target>
                        <encoding>utf8</encoding>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    
        <plugins>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>scala-compile-first</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>add-source</goal>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>scala-test-compile</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
    
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            &lt;!&ndash; 打包插件 https://cloud.tencent.com/developer/ask/187585 &ndash;&gt;
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>${maven.package.version}</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            &lt;!&ndash;<transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.spark.project.applications.passiveasset.PassiveAssetDayRDDApp
                                    </mainClass>
                                </transformer>
                            </transformers>&ndash;&gt;
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>-->
    
        <!-- https://dongkelun.com/2019/07/16/ideaMavenScalaJava/ -->
        <plugins>
            <plugin>
                <groupId>org.scala-tools</groupId>
                <artifactId>maven-scala-plugin</artifactId>
                <version>2.15.2</version>
                <executions>
                    <execution>
                        <id>scala-compile-first</id>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/*.scala</include>
                            </includes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>scala-test-compile</id>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
    
            <!-- https://www.iteye.com/blog/li200429-1745361  打包所有的依赖jar到target的lib目录下-->
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <includeTypes>jar</includeTypes>
                    <overWriteSnapshots>true</overWriteSnapshots>
                    <type>jar</type>
                    <outputDirectory>${project.build.directory}/lib</outputDirectory>
                </configuration>
            </plugin>
    
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${maven.compiler.source.version}</source>
                    <target>${maven.compiler.target.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <!-- The configuration of the plugin -->
                <configuration>
                    <!-- Configuration of the archiver -->
                    <archive>
    
                        <!--
                            生成的jar中,不要包含pom.xml和pom.properties这两个文件
                        -->
                        <addMavenDescriptor>false</addMavenDescriptor>
    
                        <!-- Manifest specific configuration -->
                        <manifest>
                            <!--
                                是否要把第三方jar放到manifest的classpath中
                            -->
                            <addClasspath>true</addClasspath>
                            <!--
                               生成的manifest中classpath的前缀,因为要把第三方jar放到lib目录下,所以classpath的前缀是lib/
                           -->
                            <classpathPrefix>lib/</classpathPrefix>
                        </manifest>
                    </archive>
    
                </configuration>
            </plugin>
    
        </plugins>
    </build>
    
  • 相关阅读:
    刷题-力扣-剑指 Offer 22. 链表中倒数第k个节点
    刷题-力扣-617. 合并二叉树
    刷题-力扣-1109. 航班预订统计
    刷题-力扣-606. 根据二叉树创建字符串
    刷题-力扣-563. 二叉树的坡度
    扛把子组20191017-8 alpha week 2/2 Scrum立会报告+燃尽图 07
    20191017-7 alpha week 2/2 Scrum立会报告+燃尽图 06
    20191017-6alpha week 2/2 Scrum立会报告+燃尽图 05
    扛把子组20191017-5 alpha week 2/2 Scrum立会报告+燃尽图 04
    记第一次 团建
  • 原文地址:https://www.cnblogs.com/hexu105/p/12427210.html
Copyright © 2020-2023  润新知