Implementing the backend

Having established a sense of direction by specifying the various use cases of our application and setting up a database for our application to connect to, let us go straight ahead with its implementation. Open IntelliJ IDEA and create a new project with the Spring initializer. Upon clicking Next, IntelliJ will retrieve the Spring initializer, after which you will be asked to provide certain details for the application. Do the following before proceeding to the next stage of the setup:

  1. Input com.example as the group ID.
  2. Enter place-reviewer as the artifact ID.
  3. Select Maven Project as the project type if it is not already selected.
  4. Leave the packaging option and Java version the way they are.
  5. Select Kotlin as the language. This is important, as we are further learning the Kotlin language, after all.
  6. Change the version attribute to 1.0.0.
  7. Enter a description of your choice. Ours is A nifty web application for the creation of location reviews.
  8. Input com.example.placereviewer as the package name.

After filling in the required project information, proceed to the next screen by clicking Next. We are required to select the dependencies of our project in the screen displayed to us.

The Spring initializer comes with the Spring plugin, which, at the time of writing, is only available on the IntelliJ IDEA Ultimate Edition, which requires a paid license. If you have the IntelliJ IDEA Community Edition installed, you can still develop this application. Simply generate the project using the Spring initializer utility at https://start.spring.io and import the project into IntelliJ IDEA.

Select the Spring Security, Session, Cache, and Web dependencies. In addition, select Thymeleaf from the template engine category. Under the SQL category, select PostgreSQL. In addition, in the Spring Boot Version selection dropdown menu at the top of the screen, select 2.0.0 M7 as the version. Upon selecting the necessary dependencies, the content should be similar to that in the following screenshot:

After asserting that you have selected the appropriate dependencies, click Next to continue to the final setup screen. Here, you are required to provide a project name and a project location. Fill in place-reviewer as the project name and select the location in which you want the project to be saved on your computer:

Once this has been done, select Finish and wait for the project to be set up. You will be taken to a new IDE window containing the initial project files. We need not give any introductions to the structure of a Spring project, as we have already worked with one in previous chapters. Before we go further, add the following dependencies to the project's pom file:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>4.0.0-beta.3</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.2.1</version>
</dependency>

Now, let's get on with connecting our application to our database.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.210.205