scala开发环境配置(windows环境)

举报
Amrf 发表于 2020/01/16 19:13:00 2020/01/16
【摘要】 确认系统已经安装java8或以上的jdk下载scala-2.11.8.msihttps://www.scala-lang.org/download/all.html下载sbt-1.2.8.msihttps://www.scala-sbt.org/download.html分别安装scala和sbt配置sbt修改sbt/conf/sbtconfig.txt-Xmx512M-XX:MaxPerm...

确认系统已经安装java8或以上的jdk

下载scala-2.11.8.msi

https://www.scala-lang.org/download/all.html

下载sbt-1.2.8.msi

https://www.scala-sbt.org/download.html

分别安装scala和sbt

配置sbt

  1. 修改sbt/conf/sbtconfig.txt

-Xmx512M
-XX:MaxPermSize=256m
-XX:ReservedCodeCacheSize=128m
-Dsbt.log.format=true
# 如果需要修改源
-Dsbt.override.build.repos=true
# 如果希望修改本地仓地址
-Dsbt.boot.directory=D:/sbt/.sbt/boot
-Dsbt.ivy.home=D:/sbt/.ivy2
-Dsbt.global.base=D:/sbt/.sbt
-Dsbt.repository.config=D:/sbt/repositories
# 如果需要设置代理
-Dsbt.repository.secure=false
-Dhttp.proxyHost=proxyhost
-Dhttp.proxyPort=proxyport
-Dhttp.proxyUser=user
-Dhttp.proxyPassword=password
-Dhttps.proxyHost=proxyhost
-Dhttps.proxyPort=proxyport
-Dhttps.proxyUser=user
-Dhttps.proxyPassword=password

2.修改源,如果sbt.repository.config不设置,需要在用户目录下的.sbt中新建repositories文件,设置了则在设置的目录中创建

如果使用华为云的sbt镜像则内容修改为

[repositories]
  local
  huaweicloud-ivy: https://mirrors.huaweicloud.com/repository/ivy/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
  huaweicloud-maven: https://mirrors.huaweicloud.com/repository/maven/


下载并安装idea,下载scala-intellij-bin-2019.2.15.zip插件,解压到idea插件目录

打开idea,新建scala-sbt项目

  1. 设置sbt为系统安装的版本而不是idea内置的

    image.png

    vm参数的设置和sbtconfig.txt一样, 启动器为安装的sbt启动器文件路径

  2. 为项目添加scala-sdk

    image.png

    添加成功后会出现在modules中

    image.png

  3. 设置scala目录为源目录( 注意不设置会导致找不到主类入口)

    image.png

  4. 在scala目录下新建com目录,并添加HelloWord.scala文件,内容为


    package com
    
    object HelloWorld{
      def main (args: Array[] ): Unit = {
          print("Hello World!")
      }
    }


  5. 右键运行HelloWorld文件


参考:

https://gist.github.com/wsargent/072319c2100ac0aea4305d6f6eeacc08

https://blog.csdn.net/lovehuangjiaju/article/details/47746391

https://blog.csdn.net/iamlihongwei/article/details/72783459

https://stackoverflow.com/questions/13803459/how-to-use-sbt-from-behind-proxy

https://blog.csdn.net/liuxiao723846/article/details/80734490

https://stackoverflow.com/questions/52222156/scala-sbt-error-while-importing-sbt-project

https://stackoverflow.com/questions/41351282/sbt-launcher-does-not-exist-when-attempting-to-open-sbt-project-in-intellij

https://blog.csdn.net/jameshadoop/article/details/52295710

https://blog.csdn.net/hongzhen91/article/details/81507140

https://blog.csdn.net/difffate/article/details/80631964

https://blog.csdn.net/yu0_zhang0/article/details/79237210

https://stackoverflow.com/questions/44163744/could-not-find-or-load-main-class-in-scala-in-intellij-ide

其他:

https://docs.google.com/document/d/1W38UZuDkPrVwxWjjCIQaXNftnpVyYHUE4icLQ4XbGAU/edit?pli=1

https://www.toptal.com/scala/why-should-i-learn-scala

https://contributors.scala-lang.org/t/what-can-make-scala-more-popular/2995

https://www.educative.io/blog/the-resurgence-of-scala-in-2019

https://hackernoon.com/10-reasons-to-learn-scala-and-functional-programming-2fce385e6ec7

https://stackoverflow.com/questions/15241903/what-can-i-do-in-scala-that-i-could-not-do-in-java

https://www.grahamlea.com/2013/02/a-new-java-library-for-amazing-productivity/

https://stackoverflow.com/tags/scala/info

https://stackoverflow.com/questions/2952732/samples-of-scala-and-java-code-where-scala-code-looks-simpler-has-fewer-lines/2953040


【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。