在gx works2程序中怎样对aj65sbt
1、scala是什么 其实,scala是 一种语法,类似Java,而sbt是 一个构建工具,类似maven,gradle,ant等。
在eclipse中只有scala开发环境的插件,可以构建scala project,但是没有sbt 插件,就像没有maven插件的eclipse,只能构建和编辑java project,但是整不了maven project。
2、 构建步骤1)构建Scala语言环境 ,和java一样,主要分两步:下载软件、配置HOME和Path.2)安装SBT 工具,下载、配置全局变量(在windows环境中添加sbt.bat脚本,可以直接运行)3)使用SBT生成一个类似maven 包结构的scala project。
3、实际操作1)新建一个目录叫 test2)在test目录中新建文件build.sbt3)在test目录新建project目录,进入project目录,并新建plugins.sbt,在其中添加 addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.4.0")4)在build.sbt中配置工程的name,scala编译环境,依赖等等。
如:import sbt._ import Process._ import Keys._ EclipseKeys.createSrc := EclipseCreateSrc.Default + EclipseCreateSrc.Resource lazy val commonSettings = Seq( name := "test", organization := "com.marsyoung", version := "0.0.1-SNAPSHOT", scalaVersion := "2.11.7") lazy val root = (project in file(".")). settings(commonSettings: _*). settings( libraryDependencies ++= Seq( "junit" % "junit" % "4.4", "javax.ws.rs" % "jsr311-api" % "1.1.1" ) )5)在cmd中进入对应的project目录,即test目录。
运行sbt。
6)执行eclipse命令,将对应的项目转化成可以引入eclipse开发工具并且目录结构类似maven的项目。
7)打开已经安装了scala ide的eclipse,导入对应的project,会自动的编译成scala peoject.4、小提示 SBT配置使其支持本地maven和私服,如下:在用户根目录下的.sbt文件夹内,在windows下就是C->用户->用户名->.sbt目录下新建repositories文件并插入内容:[repositories] local activator-launcher-local: file:////${activator.local.repository-${activator.home-${user.home}/.activator}/repository}, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext] activator-local: file:////${activator.local.repository-D:/maven/repo3.3.1} sohu-public: http://xxx.com/nexus/content/groups/public typesafe-releases: http://repo.typesafe.com/typesafe/releases typesafe-ivy-releasez: http://repo.typesafe.com/typesafe/ivy-releases, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext] sonatype-oss-releases sonatype-oss-snapshots maven-central 本地maven地址为:D:/maven/repo3.3.1
半壁江山难稳固