Idea使用Maven编译scala和打包jar

IntelliJ IDEA打jar包--scala class--提交到java或者spark运行 编译文件并且打成jar包,运行jar包 第一步:file–>artifacts填写相关内容后返回 第二步:build–>build artifacts–>build 在刚刚我们选择的保存目录下找到.jar文件 第三步:提交运行 在java下运行 在spark-shell中提交运行 不加spark-shell的路径提交也OK ... 阅读详情

下面Maven的pom文件

[html]  view plain  copy
  1. <properties>  
  2.     <maven.compiler.source>1.7</maven.compiler.source>  
  3.     <maven.compiler.target>1.7</maven.compiler.target>  
  4.     <encoding>UTF-8</encoding>  
  5.     <scala.version>2.11.7</scala.version>  
  6.     <scala.compat.version>2.11</scala.compat.version>  
  7. </properties>  
  8.   
  9. <dependencies>  
  10.   
  11.     <dependency>  
  12.         <groupId>org.scala-lang</groupId>  
  13.         <artifactId>scala-library</artifactId>  
  14.         <version>${scala.version}</version>  
  15.     </dependency>  
  16. </dependencies>  
  17.   
  18. <build>  
  19.     <!--scala待编译的文件目录-->  
  20.     <sourceDirectory>src/main/scala</sourceDirectory>  
  21.     <testSourceDirectory>src/test/scala</testSourceDirectory>  
  22.     <!--scala插件-->  
  23.     <plugins>  
  24.         <plugin>  
  25.             <groupId>net.alchim31.maven</groupId>  
  26.             <artifactId>scala-maven-plugin</artifactId>  
  27.             <version>3.2.2</version>  
  28.             <executions>  
  29.                 <execution>  
  30.                     <goals>  
  31.                         <goal>compile</goal>  
  32.                         <goal>testCompile</goal>  
  33.                     </goals>  
  34.                     <configuration>  
  35.                         <args>  
  36.                             <!--<arg>-make:transitive</arg>--><!--scala2.11 netbean不支持这个参数-->  
  37.                             <arg>-dependencyfile</arg>  
  38.                             <arg>${project.build.directory}/.scala_dependencies</arg>  
  39.                         </args>  
  40.                     </configuration>  
  41.                 </execution>  
  42.             </executions>  
  43.         </plugin>  
  44.   
  45.         <!--manven打包插件-->  
  46.         <plugin>  
  47.             <groupId>org.apache.maven.plugins</groupId>  
  48.             <artifactId>maven-shade-plugin</artifactId>  
  49.             <version>2.4.3</version>  
  50.             <executions>  
  51.                 <execution>  
  52.                     <phase>package</phase>  
  53.                     <goals>  
  54.                         <goal>shade</goal>  
  55.                     </goals>  
  56.                     <configuration>  
  57.                         <filters>  
  58.                             <filter>  
  59.                                 <artifact>*:*</artifact>  
  60.                                 <excludes>  
  61.                                     <exclude>META-INF/*.SF</exclude>  
  62.                                     <exclude>META-INF/*.DSA</exclude>  
  63.                                     <exclude>META-INF/*.RSA</exclude>  
  64.                                 </excludes>  
  65.                             </filter>  
  66.                         </filters>  
  67.                         <transformers>  
  68.                             <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">  
  69.                                 <resource>reference.conf</resource>  
  70.                             </transformer>  
  71.                             <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">  
  72.                                 <mainClass>cn.itcast.rpc.Master</mainClass> <!--main方法-->  
  73.                             </transformer>  
  74.                         </transformers>  
  75.                     </configuration>  
  76.                 </execution>  
  77.             </executions>  
  78.         </plugin>  
  79.     </plugins>  
  80. </build>  

上面是使用Scala2.11的版本,注意scala2.11 netbean不支持这个参数-make:transitive这个参数,所以必须得注释掉

下面是简单的测试:



使用Maven进行jar依赖打包,之前使用Idea的artifacts进行打包,但是导出的jar有可能因为缺少某些信息而无法直接运行,但是使用maven自动的pakage便没有这个问题,而且jar包的大小明显小于artifacts的jar包大小,下面是使用方法


下载完相关的依赖后,会在target的目录下生成下项目的jar包


IDEA Maven打包Scala可执行jar IDEA+Maven打包Scala可执行jar pom.xml插件配置 <build> <sourceDirectory>src/main/scala</sourceDirectory> <testSourceDirectory>src/test/scala</testSourceDirectory> <plugins> <plugin> <groupId>or 阅读详情

相关推荐

使用idea和maven开发和打包scala和spark程序

使用idea构建maven管理的scala和spark程序,默认已经装好了idea、scala并在idea中安装了scala插件。一、新建Maven项目二、Hello world三、导入spark依赖四、编写spark代码五、打包到服务器spark运行...

蓝色水彼的博客 6198

使用IDEA进行scala打包运行

前言 IDEA的安装、创建maven工程和scala编程不是本文的重点,这里主要介绍打包并放至spark集群上运行的方法。(具体安装和配置操作的参考链接:https://blog.youkuaiyun.com/s863222424/article/details/102979162 具体步骤 创建一个scala class文件,写上一段简单的scala代码。 package main.scala obj...

qq_45864778的博客 3956

Hudi0.14.0 集成 Spark3.2.3(IDEA编码方式)

Hudi0.14.0 集成 Spark3.2.3(IDEA编码方式)

跟着大数据和AI去旅行 722

使用IDEA配置sbt,编译打包Scala代码

IDEA配置sbt,编译打包Scala代码

qq_52147555的博客 2938

白炽灯寿命工程解析:从钨丝蒸发到电压控制的可靠性设计

白炽灯作为一种经典的电光源,其工作原理基于电流通过钨丝产生热辐射发光。在高温下,钨丝会持续蒸发导致灯丝逐渐变细、电阻增大,这是影响其寿命的核心物理机制。从工程角度看,白炽灯的可靠性设计涉及材料科学、热力学和电路设计的交叉,技术价值在于通过理解其失效原理,可以在成本与性能间取得最佳平衡。在实际应用中,电压波动、开关浪涌电流和机械振动是主要寿命杀手,尤其在工业控制、仪器仪表和特定照明场景中,合理的设计能大幅提升系统稳定性。本文深入探讨了钨蒸发、热应力等关键因素,并结合浪涌抑制和降压设计等实战技巧,为工程师提供了

weixin_28684655的博客 570

实战指南:在摩尔线程GPU上部署AI模型的完整流程

本文提供了一份详尽的实战指南,手把手教你如何在摩尔线程GPU上成功部署AI模型。内容涵盖从驱动安装、Docker环境配置,到核心的代码适配与模型运行全流程,并分享了性能调优技巧与常见避坑方法,旨在帮助开发者高效利用国产硬件进行AI应用开发。

weixin_29271263的博客 541

将Scala编译成.class文件和依赖打包的插件

<build> <plugins> <plugin> <groupId>org.scala-tools</groupId> <artifactId>maven-scala-plugin</artifactId> <version>2.15.1</version&g...

m0_48379126的博客 970

波克 上海 Unity开发笔试题 2024

主要分为四部分,如果没有准备好,不要点击笔试链接,进入就会自动开始。

z2014z的博客 3396

Idea打包:scala打成jar包

file > project Structure > Artifacts > + > jar > from modules..... >OK (什么都不用选,直接OK) > 相关依赖包全删,留一个即可。在工具栏找到Build > Build Artifacts > build。scp /本地/文件/路径 用户名@服务器IP地址:/服务器/目标/路径。在底部找到Terminal在这里输入上传命令。

m0_75028327的博客 1800

LangChain开发避坑指南:为什么Pylance总提示‘无法解析导入‘?实测7种修复方案

本文深入解析了在VS Code中使用LangChain开发时,Pylance频繁提示‘无法解析导入’的根本原因——Python解释器与语言服务器的环境路径不一致。文章提供了从基础排查到深度配置的7种实测修复方案,包括切换解释器、配置extraPaths、使用pyrightconfig.json等,旨在帮助开发者彻底解决此问题,提升AI应用开发效率。

weixin_28826521的博客 447

别再只调API了!深度拆解Dify文件上传的两种传参方式(sys.file vs. inputs.upload_file)

本文深度解析Dify平台文件上传的两种传参方式——sys.file与inputs.upload_file,详细对比其设计原理、技术实现及适用场景。通过代码示例和性能分析,帮助开发者在本地大模型应用中做出精准技术选型,提升文件处理效率与系统稳定性。

weixin_29063979的博客 268

Idea16使用Maven编译scala和打包jar

下面Maven的pom文件 1.7 1.7 UTF-8 2.11.7 2.11 org.scala-lang scala-library ${scala.version}

Javis486的专栏 8997

天猫精灵设备拆机及系统分析

我手头的这个天猫精灵型号为TG_X1,黑色天猫精灵AI助手,拆解没有多少难度,但需要注意连接线的问题。具体的拆机过程可以参见:http://www.geekifix.com/wp/archives/415.html注意一点就是,天猫精灵的主板的位置,位于音频按键的底部,也就是顶端,而拆解是从电源的位置从低到顶进行拆机;拆机后,看到主控板的信息如下:主控型号:联发科 MT8516MT8516支持四核...

LeeKwen的专栏 3万+

idea-Scala开发pom文件

idea-Scala开发pom文件 <build> <sourceDirectory>src/main/scala</sourceDirectory> <testSourceDirectory>src/test/scala</testSourceDirectory> <plugins> <!--scala编译器--> <plugi

扛着锄头的码农 909

渗透测试之哥斯拉实战

可以直接在这里使用meterpreter命令进行对服务端的控制。选择目标 - 添加,配置连接信息,之后测试连接成功!php的shell功能如图。先要进行数据库的配置信息。可以直接在这里打包全站。

大河之犬的博客 2488

UMI——斯坦福刷盘机器人:通过手持夹爪革新数据收集方式,且使用视觉SLAM和Diffusion Policy预测动作

没想到今年年初的斯坦福mobilealoha的热度刚过,而到今年2月的下旬,斯坦福另一个团队又推出了UMI刷盘机器人,且这两个团队还互相认识、还在一块共同切磋(顺带小小感叹一下,斯坦福的氛围是真好而且真高产)斯坦福UMI刷盘机器人其与mobile aloha(以及AirExo: Low-Cost Exoskeletons for Learning Whole-Arm Manipulation in the Wild)最大的不同在于其收集数据处理的非真实的机器人,而是一个手持夹持器(从而大幅降低成本)

u013250861的博客 1357

idea+maven+scala+spark-submit打包上传报ClassNotFoundException,找不自定义的类

报错原因原因一:maven打包失败,没有加入将scala编译原因二:spark-submit参数写的不对,class后面需要全类名原因三:jar包上传失败,不完整 java.lang.ClassNotFoundException: com.xxx.xxx at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.jav

qq_44628081的博客 990

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

利用IDEA将项目打包(两种方法)

1.首先需要创建maven项目 2.在maven项目管理中要加上相关依赖,我这里把所有的东西都贴上来 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSch...

杨小妹的刘小哥 1万+

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

在IDEA中编写spark程序

这里以一个scala版本的word count 程序为例:①创建一个maven项目:②填写maven的GAV:③填写项目名称:④ 创建好 maven 项目后,点击 Enable Auto-Import⑤配置pom.xml文件: <properties> <project.build.sourceEncoding>UTF8</project.build.so...

weixin_33875839的博客 488

maven scala java 混合项目编译、打包(jar包)、运行

文章目录说明java相关的插件scala相关的插件maven命令打包创建项目分别指定java和scala的source root路径编辑pom文件执行命令运行jaridea打包参考资料 说明 一开始用的是在idea中打包的方式,但是在更新项目结构或是更新以来后,需要手动的去修改原来的配置,不是很方便。于是查找资料看下用maven命令如何打包 java相关的插件 java代码编译与打包,我参考了这篇文章的内容,介绍的很详细:https://blog.youkuaiyun.com/dyq51/article/details

枪枪枪的博客 9284

Maven工程打jar包的N种方式

Idea;Maven工程;jar包;N种方式

Hugh_Guan的博客 3万+

intellij idea 打可运行scala jar 包的两种方式

今天折腾了一天 研究 idea 打可运行scala 代码的 jar 包。有些心得记录下来,供大家参考,希望能帮助到一些同事。 此前在网络上有一些关于打jar 包的资料,大都是一些转载,或者介绍的不是很详细。此篇是详细介绍打包过程以及思考推导方式,供大家参考。 此文章分为 通过IDEA 打可执行jar 包和 通过 idea maven 打可执行jar 包两种方式介绍。 IDEA 打可执

freecrystal_alex的博客 2万+

spark开发环境搭建(基于idea 和maven) 以及 maven打包jar包的两种方式 转

spark开发环境搭建(基于idea 和maven) 转载 文章出自:http://blog.youkuaiyun.com/u012373815/article/details/53266301 使用idea构建maven 管理的spark项目 ,默认已经装好了idea 和Scala 那么使用idea 新建maven 管理的spark 项目有以下几步: scala插件的安装 全局JDK和Libra...

qq_38250124的博客 6696

idea,maven打包spark程序(scala)的jar文件

1.new-->project--->maven 填入GroupId和ArtifactId(相当于给你的项目起名字) 2.在pom.xml中标签中建立标签 3.在http://mvnrepository.com/ 中找到你要添加的包 复制到pom.xml中的中,保存 4.删除test 以及main中的java文件夹 5.main中新建scala文件夹 6.右击项目--

caozhanweicaiyuli的博客 1757
上一篇: Eclipse 启动时提示loading workbench错误并提示查看.log
下一篇: 在eclipse上安装Scala插件
TheManOfCoding
博客等级 码龄9年 24粉丝 21原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值