当前位置: 首页 > news >正文

scala代码打包配置(maven)

目录

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

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.lryc.cn/news/520342.html

相关文章:

  • 慧集通(DataLinkX)iPaaS集成平台-业务建模之业务对象(二)
  • C++使用minio-cpp库在minio中创建bucket
  • 【大模型】大语言模型的数据准备:构建高质量训练数据的关键指南
  • 【解决】okhttp的java.lang.IllegalStateException: closed错误
  • TCP-IP详解卷 TCP的超时与重传
  • Linux服务器查看【可用端口号连接】的命令和方式【netstat,ss,lsof】
  • 【WPS】【WORDEXCEL】【VB】实现微软WORD自动更正的效果
  • Attention计算中的各个矩阵的维度都是如何一步步变化的?
  • 【数模学习笔记】插值算法和拟合算法
  • 探索 C++ 与 LibUSB:开启 USB 设备交互的奇幻之旅
  • 二、模型训练与优化(4):模型优化-实操
  • 3D可视化产品定制,应用于哪些行业领域?
  • Avalonia 入门笔记(零):概述
  • Unity TextMesh Pro入门
  • [论文阅读] (35)TIFS24 MEGR-APT:基于攻击表示学习的高效内存APT猎杀系统
  • 12 USART串口通讯
  • CF 368A.Sereja and Coat Rack(Java实现)
  • 清华大学、字节跳动等单位联合发布最新视觉语言动作模型RoboVLMs
  • 网络安全、Web安全、渗透测试之笔经面经总结
  • .NET Core NPOI 导出图片到Excel指定单元格并自适应宽度
  • python bs4 selenium 查找a href=javascript:();的实际点击事件和url
  • 三 BH1750 光感驱动调试1
  • UE材质节点Fresnel
  • linux的大内核锁与顺序锁
  • 用户注册模块用户校验(头条项目-05)
  • 面向对象的基本概念
  • 深度学习每周学习总结R4(LSTM-实现糖尿病探索与预测)
  • 如何使用 PHP 操作亚马逊 S3 对象云存储
  • 26_Redis RDB持久化
  • 标准Android开发jdk和gradle和gradle AGP和AndroidStudio对应版本