日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

maven构建scala工程并最终运行的所有细节(scala maven helloworld)

發(fā)布時間:2023/12/20 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 maven构建scala工程并最终运行的所有细节(scala maven helloworld) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

琢磨了很久,網(wǎng)上雖然各種例子,但是好多都是依賴IDE的,要么就是生成jar文件后沒有主清單目錄,寫這篇博客一次性全部解決掉。

1,文件目錄

(python2.7) appleyuchi@ubuntu:~/Desktop/test3/scala-module-dependency-sample/maven-sample$ ls
pom.xml ?src

. ├── pom.xml ├── src │?? └── main │?? └── scala │?? └── XMLHelloWorld.scala

2.pom.xml

<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/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><groupId>sample</groupId><artifactId>scala-module-dependency-sample</artifactId><version>1.0-SNAPSHOT</version><!-- Maven profiles allow you to support both Scala 2.10, 2.11 and Scala 2.12 withthe right dependencies for modules specified for each version separately --><profiles><profile><id>scala-2.12</id><activation><activeByDefault>true</activeByDefault></activation><properties><scalaVersion>2.12.0</scalaVersion><scalaBinaryVersion>2.12</scalaBinaryVersion></properties><dependencies><dependency><groupId>org.scala-lang</groupId><artifactId>scala-library</artifactId><version>${scalaVersion}</version></dependency><dependency><groupId>org.scala-lang.modules</groupId><artifactId>scala-xml_${scalaBinaryVersion}</artifactId><version>1.0.6</version></dependency><dependency><groupId>org.scala-lang.modules</groupId><artifactId>scala-parser-combinators_${scalaBinaryVersion}</artifactId><version>1.0.4</version></dependency><dependency><groupId>org.scala-lang.modules</groupId><artifactId>scala-swing_${scalaBinaryVersion}</artifactId><version>2.0.0-M2</version></dependency></dependencies></profile><profile><id>scala-2.11</id><properties><scalaVersion>2.11.8</scalaVersion><scalaBinaryVersion>2.11</scalaBinaryVersion></properties><dependencies><dependency><groupId>org.scala-lang</groupId><artifactId>scala-library</artifactId><version>${scalaVersion}</version></dependency><dependency><groupId>org.scala-lang.modules</groupId><artifactId>scala-xml_${scalaBinaryVersion}</artifactId><version>1.0.6</version></dependency><dependency><groupId>org.scala-lang.modules</groupId><artifactId>scala-parser-combinators_${scalaBinaryVersion}</artifactId><version>1.0.4</version></dependency><dependency><groupId>org.scala-lang.modules</groupId><artifactId>scala-swing_${scalaBinaryVersion}</artifactId><version>1.0.2</version></dependency></dependencies></profile><profile><id>scala-2.10</id><properties><scalaVersion>2.10.6</scalaVersion><scalaBinaryVersion>2.10</scalaBinaryVersion></properties><dependencies><dependency><groupId>org.scala-lang</groupId><artifactId>scala-library</artifactId><version>${scalaVersion}</version></dependency><dependency><groupId>org.scala-lang</groupId><artifactId>scala-swing</artifactId><version>${scalaVersion}</version></dependency></dependencies></profile></profiles><build><sourceDirectory>src/main/scala</sourceDirectory><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>1.6</source><target>1.6</target></configuration></plugin><plugin><groupId>net.alchim31.maven</groupId><artifactId>scala-maven-plugin</artifactId><version>3.2.1</version><executions><execution><goals><goal>compile</goal><goal>testCompile</goal></goals></execution></executions><configuration><args><!-- work-around for https://issues.scala-lang.org/browse/SI-8358 --><arg>-nobootcp</arg></args></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-shade-plugin</artifactId><version>1.2.1</version><executions><execution><phase>package</phase><goals><goal>shade</goal></goals><configuration><transformers><transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"><mainClass>XMLHelloWorld</mainClass></transformer></transformers></configuration></execution></executions></plugin></plugins></build> </project>

3.XMLHelloWorld.scala

object XMLHelloWorld {def main(args: Array[String]): Unit = {val xml = <hello>world</hello>println(xml)} }

4.

cd /home/appleyuchi/Desktop/test3/scala-module-dependency-sample/maven-sample/

mvn clean scala:compile compile package

cd target
java -jar scala-module-dependency-sample-1.0-SNAPSHOT.jar

得到結果:
<hello>world</hello>

總結下:

準備好文件夾路徑,準備好兩個文件:pom.xml和XMLHelloWorld.scala,

然后使用mvn命令,最后運行生成jar包,即可。

?

總結

以上是生活随笔為你收集整理的maven构建scala工程并最终运行的所有细节(scala maven helloworld)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。