Using Lagom with Java and sbt

If you have the prerequisites installed and are familiar with sbt, follow the steps below to create a Hello World project. Otherwise, see detailed instructions for help setting up the prerequisites and getting started. Prerequisites for using Lagom with sbt include:

  • JDK 8
  • sbt 0.13.13

The Lagom Giter8 template makes it easy to get started. The template downloads all dependencies and creates the basic project structure. It can take a few seconds to a few minutes to complete.

After confirming the prerequisites, open a console or command window and follow these steps:

  1. Create a new directory for your project.

  2. Change into the new directory and enter the following:

    sbt -Dsbt.version=0.13.15 new https://github.com/lagom/lagom-java.g8
  3. The sbt Lagom template prompts for the following parameters. Press Enter to accept the defaults for the following:

    • name - Becomes the name of the top-level directory.
    • organization - Used as a package name.
    • version - A version number for your system.
    • lagom_version - The version number of Lagom. Be sure to use the current stable release (1.3.5)
  4. Change into the top-level directory of the project you just created. For example, if you used the default name, hello:

    cd hello
  5. Start sbt and the Lagom development environment:

    sbt runAll
  6. It will take a bit of time for the services to start. When finished, the console displays the message 'Services started, ...'. Verify that the services are indeed up and running by invoking the hello service endpoint from any HTTP client, such as a browser: http://localhost:9000/api/hello/World

    The request returns the message Hello, World!.

Congratulations! You've created and run your first Lagom system. See the documentation to understand your new project.