In this tutorial, you’ll see how to create a Scala project from a template. You can use this as a starting point for your own projects. We’ll use sbt, the de facto build tool for Scala. sbt compiles, runs, and tests your projects among other related tasks. We assume you know how to use a terminal.
- hello-world - project (sbt uses this to install and manage plugins and dependencies) - build.properties - src - main - scala (All of your scala code goes here) - Main.scala (Entry point of program) <-- this is all we need for now - build.sbt (sbt's build definition file)
After you build your project, sbt will create more target directories for generated files. You can ignore these.
Changing gears a bit, let’s look at how to use published libraries to add extra functionality to our apps.
Open up build.sbt and add the following line:libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.1"
Here, libraryDependencies is a set of dependencies, and by using +=, we’re adding the scala-parser-combinators dependency to the set of dependencies that sbt will go and fetch when it starts up. Now, in any Scala file, you can import classes, objects, etc, from scala-parser-combinators with a regular import.
You can find more published libraries on Scaladex, the Scala library index, where you can also copy the above dependency information for pasting into your build.sbt file.
Note for Java Libraries: For a regular Java library, you should only use one percent (%) between the organization name and artifact name. Double percent (%%) is a specialisation for Scala libraries. You can learn more about the reason for this in the sbt documentation.
Continue to the next tutorial in the getting started with sbt series, and learn about testing Scala code with sbt in the command line.
or
Continue learning Scala interactively online on Scala Exercises. Learn about Scala’s features in bite-sized pieces by stepping through our Tour of Scala.相关知识
Getting Started with Scala and sbt on the Command Line
Getting Started
The Ultimate Guide to Getting Started with the Play Framework
Documentation
Getting Started with Oracle GraalVM
Generating Your SSH Public Key
Spark大数据分析入门
Scala中的==与equals
R Tools for Visual Studio
Alienware Command Center 应用程序快速指南
网址: Getting Started with Scala and sbt on the Command Line https://m.huajiangbk.com/newsview2270788.html
上一篇: Spring Cloud Tas |
下一篇: 哪些花卉比较适合室内摆放 最好是 |