Lightbend Activator

Slick Akka-HTTP

Activator will be EOL-ed on May 24, 2017.

We’re making it easier and simpler for developers to get started with Lightbend technologies. This unfortunately means that future releases of Play, Akka and Scala will no longer include Activator support, and Lightbend’s Activator server will be decommissioned by the end of 2017. Instead of supporting Activator to create and set up development projects, we'll be supporting standard Giter8 templates for sbt users and Maven archetypes for Maven users. So going forward,

To create new Lightbend projects

Instead of using the Activator command, make sure you have sbt 0.13.13 (or higher), and use the “sbt new” command, providing the name of the template. For example, “$ sbt new akka/hello-akka.g8”. You can find a list of templates here.

Also, as a convenience, the Lightbend Project Starter allows you to quickly create a variety of example projects that you just unzip and run.

To create new templates

If you want to create new templates, you can now do that in Giter8.

To migrate templates from Activator to Giter8

If you created Activator templates in the past, please consider migrating them to Giter8 with this simple process.

Slick Akka-HTTP

March 5, 2016
slick akka scala async

A starter akka-http and slick app

How to get "Slick Akka-HTTP" on your computer

There are several ways to get this template.

Option 1: Choose slick-akka-http in the Lightbend Activator UI.

Already have Lightbend Activator (get it here)? Launch the UI then search for slick-akka-http in the list of templates.

Option 2: Download the slick-akka-http project as a zip archive

If you haven't installed Activator, you can get the code by downloading the template bundle for slick-akka-http.

  1. Download the Template Bundle for "Slick Akka-HTTP"
  2. Extract the downloaded zip file to your system
  3. The bundle includes a small bootstrap script that can start Activator. To start Lightbend Activator's UI:

    In your File Explorer, navigate into the directory that the template was extracted to, right-click on the file named "activator.bat", then select "Open", and if prompted with a warning, click to continue:

    Or from a command line:

     C:\Users\typesafe\slick-akka-http> activator ui 
    This will start Lightbend Activator and open this template in your browser.

Option 3: Create a slick-akka-http project from the command line

If you have Lightbend Activator, use its command line mode to create a new project from this template. Type activator new PROJECTNAME slick-akka-http on the command line.

Option 4: View the template source

The creator of this template maintains it at

Option 5: Preview the tutorial below

We've included the text of this template's tutorial below, but it may work better if you view it inside Activator on your computer. Activator tutorials are often designed to be interactive.

Preview the tutorial


The Slick Akka Http is a very simple json rest api showing one way of using akka http with slick 3 library for database access.

It supports the following features:

  • Generic Data Access layer, create a DAL with crud for an entity with just one line
  • Models as case classes and slick models, independent from database driver and profile
  • Multiple database types configured in properties file (h2 and postgresql for instance)
  • Cake pattern for DI
  • Spray-json to parse json
  • Cake pattern for DI
  • Tests for DALs
  • Tests for routes

Utils: Typesafe config for property management and Typesafe Scala Logging (LazyLogging)


The project was thought to be used as a seed for creating akka-http projects with slick, so the implementation is minimal. The model is very simple, is a supplier with a name and description.

The rest api has a get and a post (json), a get for get all the suppliers, and a post to add suppliers. You should view this info in swagger with more detail.

For running the project go to section run, and run it.

For running the project in sbt:

    $ sbt
    > run

Slick 3

Models as case classes and slick 3 schemas extending from a BaseEntity and BaseTable

 case class Supplier(name: String,desc: String)  extends BaseEntity 
class SuppliersTable(tag: Tag) extends BaseTable[Supplier](tag, "SUPPLIERS") {
  def name = column[String]("userID")
  def desc = column[String]("last_name")
  def * = (id, name, desc) <> (Supplier.tupled, Supplier.unapply)

BaseEntity and BaseTable provide Id for the class and table.

The model definition is database independent. The database type is declared in application.conf, for each database. For instance, we use an h2 database in this example with the follow configuration:

        h2db {
          driver = "slick.driver.H2Driver$"
          db {
            url = "jdbc:h2:mem:test1"
            driver = org.h2.Driver
            keepAliveConnection = true
            numThreads = 10

Cake Pattern

This seed uses cake pattern to add the possibility to use alternative implementations of some modules, for instance, in tests, the seed uses an alternative implementation for persistence.

The seed are organized in modules: ActorModule, ConfigurationModule and PersistenceModule. When we are implementing a class/actor that uses some of this dependencies, we just mix them with the modules, or put a parameter that receives the injected modules, for instance:

        class RoutesActor(modules: Configuration with PersistenceModule)

Generic DAL

This seed has a generic slick dal that can be used to implement a crud for an entity.

The generic DAL is used in suppliers DAL as example:

        	override val suppliersDal = new BaseDalImpl[SuppliersTable,Supplier](TableQuery[SuppliersTable]) {}