首页 > 其他分享 >Maven打包Scala找不到主类入口问题

Maven打包Scala找不到主类入口问题

时间:2023-07-31 23:33:26浏览次数:37  
标签:maven Scala 主类 1.8 Maven apache org spark 2.12

Maven打包Scala项目找不到主类,参考 https://blog.csdn.net/weixin_41684423/article/details/115695713 后,加上maven-assembly-plugin依赖就OK了,完整的pom文件如下:

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

    <groupId>com.chenxii.my-spark</groupId>
    <artifactId>my-spark</artifactId>
    <packaging>pom</packaging>
    <version>1.1.0</version>
    <modules>
        <module>spark-core</module>
    </modules>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <spark.version>3.2.4</spark.version>
        <scala.version>2.12.15</scala.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.apache.spark</groupId>
                <artifactId>spark-core_2.12</artifactId>
                <version>${spark.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.spark</groupId>
                <artifactId>spark-sql_2.12</artifactId>
                <version>${spark.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <!-- java编译插件 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- scala编译插件 -->
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>3.2.2</version>
                <executions>
                    <execution>
                        <id>scala-compiler</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>add-source</goal>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>scala-test-compiler</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>add-source</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <scalaVersion>2.12.15</scalaVersion>
                </configuration>
            </plugin>
            <!-- assembly模式编译,带依赖-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <!-- 你的mainclass入口,我就是test.scala 在scala文件夹下, 目录就是scr/main/scala -->
                            <mainClass>com.chenxii.myspark.sparkcore.Test</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

标签:maven,Scala,主类,1.8,Maven,apache,org,spark,2.12
From: https://www.cnblogs.com/chenxii81/p/17595313.html

相关文章

  • Maven配置中pom.xml和setting.xml之间的关系
    在日常的开发中,我们拿IDEA举例,一般会在电脑上自行下载安装Maven,然后在IDEA中配置我们安装的Maven路径,通过修改setting.xml文件,例如配置公共的镜像仓库地址,来提高依赖下载速率;或者配置内部私有的镜像仓库地址,来引入一些私有的依赖等等。1、如何从指定的镜像仓库下载依赖如下图在......
  • scala ListBuffer 列表取循环取数据
    scalaListBuffer列表取循环取数据objectTest{defmain(args:Array[String]):Unit={varlist=scala.collection.mutable.ListBuffer(1,2,3,4,5,6,7)/*list.foreach(item=>{println(s"当前list:$list")list=list.drop(2)......
  • Scala迭代器与RDD五大属性
    Scala迭代器与RDD五大属性迭代器就是读数据的工具Scala迭代器的理解​ 迭代器是读数据的工具,例如Scala的List就提供了它自己的迭代器(读数据工具),而我们也可以自己写迭代器去读List里面的数据,而不使用List的迭代器。自己编写迭代器读List数据classMyFileIterable(filePath:S......
  • mysql udf mof escalate privilege
    原理udf=‘userdefinedfunction‘,即‘用户自定义函数’。文件后缀为‘.dll’,常用c语言编写。通过在udf文件中定义新函数,对MYSQL的功能进行扩充,可以执行系统任意命令。将MYSQL账号root转化为系统system权限。思路获取udf文件上传udf到指定位置sqlmap有现成的udf文件,分为32......
  • How do I disable maven build when using Maven 2.0 integration for eclipse
    http://stackoverflow.com/questions/2865803/how-do-i-disable-maven-build-when-using-maven-2-0-integration-for-eclipseHowdoIstopthe"Maven2.0integration"pluginfromrunningmavenbuild,whilekeeping"buildautomatically"checked......
  • Maven implicit Properties(隐含变量)
    http://www.sonatype.com/books/mvnref-book/reference/resource-filtering-sect-properties.htmlMaven:TheCompleteReference9.2. MavenPropertiesPrev:9.1. IntroductionTOCNext:9.3. ResourceFiltering9.2. MavenPropertiesYoucanuseMavenproper......
  • 使用Eclipse构建Maven的SpringMVC项目
    使用Eclipse构建Maven的SpringMVC项目      首先Eclipse需要安装Maven的插件,地址:http://m2eclipse.sonatype.org/sites/m2e。     用MyEclipse安装Maven插件,建出的Maven项目有些问题。一是,发布tomcat的时候resources总是不会被发布到tomcat下;二是,把WEB-INF下的cla......
  • mac安装maven环境并配置
    参考:https://www.bilibili.com/video/BV1mW4y1q72A/?spm_id_from=333.337.search-card.all.click&vd_source=56102d8741b60f8a5fd28fed8a3d6e46https://blog.csdn.net/hzqit520/article/details/129166916......
  • maven前言
    mvn大家都在用,但是确实是不求甚解。在真实项目中,大家只需要copy一个pom文件,修修补补,记录几个常用命令就OK了。这叫面向切面编程,专注自己的核心逻辑,但是mvn本身确实是非常复杂的工具。兼顾了CICD整个寿命周期,为此实现的插件编码总量几乎大于任何一个服务实例的开发量。往往对于......
  • 将resources和testresources交给maven管理
    就两个标签和分别管理对应模块配置文件和测试配置文件,举例说明<build><resources><resource><directory>${project.basedir}/src/main/resources</directory><filtering>true</filtering></resource></resources&g......