sbt

Scala: Popular tools, libraries, and frameworks

Table of Contents1 - Build tools2 - Testing tools3 - Database4 - Functional Programming5 - Asynchronous/parallel/concurrent programming6 - Web frameworks7 - JSON8 - HTTP clients9 - Configuration/properties10 - Many more

This page is a collection of popular tools, libraries, and frameworks for the Scala programming language.

Back to top

Build tools

Play Framework: An SBT build.sbt file for JDBC, MySQL, and Anorm

As a note to self, if you want to use JDBC, MySQL, and Anorm with the Play Framework 2.6, you’ll need a libraryDependencies entry like this in your SBT build.sbt file:

libraryDependencies ++= Seq(
    guice,
    "org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2" % Test,
    jdbc,
    "mysql" % "mysql-connector-java" % "5.1.46",
    "com.typesafe.play" %% "anorm" % "2.5.3"
)

 

Scala: How to give SBT more memory (RAM) to work with

As a brief note, I was trying to run a Scala application inside SBT today and kept getting this “out of memory” error:

[error] (run-main-0) java.lang.OutOfMemoryError: GC overhead limit exceeded
java.lang.OutOfMemoryError: GC overhead limit exceeded

The solution to the problem was to allocate more memory when I start SBT. To give SBT more RAM I first issue this command at the command line:

How to use the Lightbend Config library in a Scala or Java application

Table of Contents1 - Adding the Lightbend Config dependency2 - A Scala application that uses Lightbend Config3 - The Lightbend Config configuration file4 - Discussion

If you want to use Lightbend Config configuration files in your Scala or Java application, here’s a quick example of how to configure and use Lightbend Config in your application. In this case I’m specifically using Scala and SBT.

How to read from two databases at the same time with ScalikeJdbc

This example shows how to connect-to and read-from multiple databases with ScalikeJdbc (a Scala JDBC library). I assume you already know how to use ScalikeJdbc with one database, so I’m only going to show the code and configuration file. (I’m not going to explain the details.)

The ScalikeJdbc configuration file

My ScalikeJdbc code is in an SBT project, so the ScalikeJdbc configuration file is at src/main/resources/application.conf:

How do I generate a secret key (application key) with Play Framework 2.6?

Play Framework FAQ: How do I generate a secret key (application key) with Play Framework 2.6?

Answer: Use the playGenerateSecret command in the SBT shell. Here’s an example:

$ sbt

[Scrupal6] $ playGenerateSecret
[info] Generated new secret: TozWYjreCna1QlVBGqfK4D/C6wZyQOm9gm<9;D_KO@]n
[success] Total time: 0 s, completed Apr 4, 2018 2:21:57 PM