Play Akka HTTP server is also configurable as a embedded Play server. The simplest way to start an Play Akka HTTP Server is to use the AkkaHttpServer factory methods. If all you need to do is provide some straightforward routes, you may decide to use the String Interpolating Routing DSL in combination with the fromRouterWithComponents method:

You may want to customise some of the components that Play provides, for example, the HTTP error handler. A simple way of doing this is by using Play’s components traits, the AkkaHttpServerComponents trait is provided for this purpose, and can be conveniently combined with BuiltInComponents to build the application that it requires:

In this case, the server configuration can be overridden by overriding the serverConfig property.

To stop the server once you’ve started it, simply call the stop method:

server.stop()

Note: Play requires an application secret to be configured in order to start. This can be configured by providing an application.conf file in your application, or using the play.http.secret.key system property.

Another way is to create a Play Application via GuiceApplicationBuilder in combination with the fromApplication method: