In this blog, We’ll learn how to set up the Play Framework, we’re going to create our first project with the Play Framework using Scala. Additionally, we’ll examine its built-in testing capabilities.
We need to first install the sbt command-line tool (and at least JDK 8). In this blog, we’re using sbt version 1.6.2 to install Play Framework version 2.8.13.
We can create a new application by using the sbt new command. To create a new project using sbt you can run the following command:
sbt new playframework/play-scala-seed.g8
After loading of dependencies, the tool displays a prompt and asks us to name the new project and provide the organization name.
This template generates a Play Scala project name [play-java-seed]: knoldus-play-framework organization [com.example]: knoldus.com play_version [2.8.13]: 2.8.13 scala_version [2.13.8]: 2.13.8 Template applied in /home/knoldus/./knoldus-play-framework
Now, we can run the project from the knoldus-play-framework directory:
cd knoldus-play-framework sbt run
Now, we run the project and it may take a couple of minutes to load the dependencies, Once it is started, we can open the browser and enter the URL http://localhost:9000, Now you get the default welcome page:
Now, it’s time to load the project code into the IDE(IntelliJ IDE) and look at the directory structure.
The project structure looks like this:
The app directory contains three packages for each component of MVC(Model View Controller):
The conf directory contains the project’s configuration files:
The public directory stores the resources of the application
- CSS styslesheet
We’ll find project’s main build declarations are in build.sbt at the root of the project.
project directory contains the sbt build definitions:
Through this blog, You will get the basic knowledge about the Play framework, and also it provides us with a more concise and readable code. We explored how to set up the play framework.
for more details:- https://blog.knoldus.com/kick-start-to-a-play-framework/