scala代码打包配置(maven)

news/2025/1/11 12:33:23/

目录

  • maven
    • pom.xml打包配置项(非完整版,仅含打包的内容< build>)
    • pom.xml完整示例(需要修改参数)
    • 效果说明

maven_1">maven

最主要的方式还是maven进行打包,也好进行配置项的管理
以下为pom文件(不要忘记修改部分参数)

pom.xml打包配置项(非完整版,仅含打包的内容< build>)

  <build><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><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.0</version><configuration><source>8</source><target>8</target><encoding>UTF-8</encoding></configuration><executions><execution><phase>compile</phase><goals><goal>compile</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-shade-plugin</artifactId><executions><!-- Run shade goal on package phase --><execution><phase>package</phase><goals><goal>shade</goal></goals><configuration><filters><filter><!-- Do not copy the signatures in the META-INF folder.Otherwise, this might cause SecurityExceptions when using the JAR. --><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.ManifestResourceTransformer"><mainClass>com.wunaiieq.SSJdbcRead</mainClass></transformer></transformers><createDependencyReducedPom>false</createDependencyReducedPom></configuration></execution></executions></plugin></plugins></build>

pom.xml完整示例(需要修改参数)

<?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.wunaiieq</groupId><artifactId>spark02</artifactId><version>1.0-SNAPSHOT</version><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><dependency><groupId>org.apache.spark</groupId><artifactId>spark-core_2.12</artifactId><version>3.2.1</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.11</version><scope>test</scope></dependency><dependency><groupId>org.apache.spark</groupId><artifactId>spark-sql_2.12</artifactId><version>3.2.1</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.25</version></dependency></dependencies><build><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><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.0</version><configuration><source>8</source><target>8</target><encoding>UTF-8</encoding></configuration><executions><execution><phase>compile</phase><goals><goal>compile</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-shade-plugin</artifactId><executions><!-- Run shade goal on package phase --><execution><phase>package</phase><goals><goal>shade</goal></goals><configuration><filters><filter><!-- Do not copy the signatures in the META-INF folder.Otherwise, this might cause SecurityExceptions when using the JAR. --><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.ManifestResourceTransformer"><mainClass>com.wunaiieq.SSJdbcRead</mainClass></transformer></transformers><createDependencyReducedPom>false</createDependencyReducedPom></configuration></execution></executions></plugin></plugins></build>
</project>

效果说明

打包后会弹出两个jar包
original-spark02-1.0-SNAPSHOT.jar:默认打包配置,不含其他依赖项
spark02-1.0-SNAPSHOT.jar:涵盖所有依赖文件(dependency)
在这里插入图片描述


http://www.ppmy.cn/news/1561931.html

相关文章

丢帧常见的几种处理方法

1. 优化硬件配置 • 升级计算机硬件&#xff0c;如增加内存、使用更高速的 CPU 和存储设备&#xff0c;以提高数据处理和传输能力。• 确保相机与计算机之间的连接稳定&#xff0c;如使用高质量的数据线、合适的接口卡&#xff0c;并检查接口是否松动。 2. 调整相机参数 • 降低…

Java大厂面试题之10种分布式ID的生成方案

一、前言 日常工作中&#xff0c;我们开发的系统、或者中间件&#xff0c;都是分布式部署的。比如你的订单数据库&#xff0c;做了分库分表&#xff0c;这时候&#xff0c;你需要一个唯一的ID来标记一条数据。这时候&#xff0c;就需要分布式ID。分布式ID是在分布式系统下使用…

从 2D 图像中学习 3D 人机交互关系

一、论文背景与动机 理解3D人类与物体的交互关系&#xff08;3D Human-Object Interaction Relation, 3D HOI&#xff09;对于具身智能和交互建模至关重要。然而&#xff0c;现有的大多数方法通常通过单独预测某些交互元素&#xff08;如人类接触点、物体可供性、人-物空间关系…

【TI毫米波雷达】DCA1000不使用mmWave Studio的数据采集方法,以及自动化实时数据采集

【TI毫米波雷达】DCA1000不使用mmWave Studio的数据采集方法&#xff0c;以及自动化实时数据采集 mmWave Studio提供的功能完全够用了 不用去纠结用DCA1000低延迟、无GUI传数据 速度最快又保证算力无非就是就是Linux板自己写驱动做串口和UDP 做雷达产品应用也不会采用DCA1000的…

《分布式光纤测温:解锁楼宇安全的 “高精度密码”》

在楼宇建筑中&#xff0c;因其内部空间庞大&#xff0c;各类电器设施众多&#xff0c;如何以一种既高效又稳定&#xff0c;兼具低成本与高覆盖特性的方式&#xff0c;为那些关键线路节点开展温度监测&#xff0c;是目前在安全监测领域一项重点研究项目&#xff0c;而无锡布里渊…

4 驱动开发

环境配置 开发环境 在开发驱动程序之前,我们需要配置好开发环境, 首先安装好VS IDE(这里自己选择版本),其次因为我们需要开发驱动程序所以需要安装WDK(WDK下载地址:以前的 WDK 版本和其他下载 - Windows drivers | Microsoft Learn),在我们安装WDK时候需要注意其版本…

2025届视觉算法开发工程师面试问题汇总

2025届视觉算法开发工程师面试问题汇总 1. 数据结构1.1 时间复杂度 2. 算法问题2.1 两数之和2.2 递归求二叉树的深度2.3 一个由0和1组成数组中&#xff0c;计算出这里面连续1的最大数 3. C、Python、Cuda问题3.1 C3.1.1 智能指针3.1.1.1 std::unique_ptr独占指针3.1.1.2 std::s…