Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Spring 5.0 Projects
  • Table Of Contents Toc
  • Feedback & Rating feedback
Spring 5.0 Projects

Spring 5.0 Projects

By : Nilang Patel
3 (2)
close
close
Spring 5.0 Projects

Spring 5.0 Projects

3 (2)
By: Nilang Patel

Overview of this book

Spring makes it easy to create RESTful applications, merge with social services, communicate with modern databases, secure your system, and make your code modular and easy to test. With the arrival of Spring Boot, developers can really focus on the code and deliver great value, with minimal contour. This book will show you how to build various projects in Spring 5.0, using its features and third party tools. We'll start by creating a web application using Spring MVC, Spring Data, the World Bank API for some statistics on different countries, and MySQL database. Moving ahead, you'll build a RESTful web services application using Spring WebFlux framework. You'll be then taken through creating a Spring Boot-based simple blog management system, which uses Elasticsearch as the data store. Then, you'll use Spring Security with the LDAP libraries for authenticating users and create a central authentication and authorization server using OAuth 2 protocol. Further, you'll understand how to create Spring Boot-based monolithic application using JHipster. Toward the end, we'll create an online book store with microservice architecture using Spring Cloud and Net?ix OSS components, and a task management system using Spring and Kotlin. By the end of the book, you'll be able to create coherent and ?exible real-time web applications using Spring Framework.
Table of Contents (9 chapters)
close
close

Deploying to Tomcat

Before we proceed with View and Controller for handling views, we will deploy the app developed so far to Tomcat. You can download Tomcat 8.5 from here (https://tomcat.apache.org/download-80.cgi). Installation is as simple as extracting the ZIP/TAR file onto your file system.

Let's create a user admin and manager-gui role in Tomcat. To do this, have to edit apache-tomcat-8.5.23/conf/tomcat-users.xml and add the following line:

<role rolename="manager-gui" />
<user username="admin" password="admin" roles="manager-gui" />

Starting up Tomcat is simple, as follows: 

  1. Navigate to apache-tomcat-8.5.23/bin
  2. Run startup.bat

Navigate to http://localhost:8080/manager/html and enter admin, and admin for username and password respectively, to be able to view Tomcat's manager console. The initial part of the page will list the applications deployed in the current instance, and toward the later part of the page you will find an option to upload a WAR file to deploy the application, as shown in the following screenshot:

We can either upload the WAR file generated after running mvn package or update the server.xml of the Tomcat instance to refer to the target directory of the project to be able to deploy automatically. The latter approach can be used for development, while the former that is WAR deployment can be used for production.

In a production system, you can have a continuous deployment server generate a WAR file and deploy to a remote Tomcat instance. In this scenario, we will use the latter approach of updating the Tomcat's configuration. You have to add the following line of code in the Tomcat's server.xml file, located at TOMCAT_HOME/conf/server.xml:

<Context path="/world" docBase="<<Directory path where you keep WAR file>>" 
reloadable="true" />

The preceding line has to be added between the <Host></Host> tags. Alternatively, you can configure Tomcat in your IDE (for example, Eclipse), which is more convenient for development purposes. We will build the project with Maven, but before that, please add following configuration to the <properties></properties> section of pom.xml:

<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>

This will make sure to choose the correct Java compiler version while building (packaging) the application with Maven from the command line. Next is to build the project using the mvn package and run Tomcat using TOMCAT_HOME/bin/startup.bat, and once the server is UP, you can visit the API http://localhost:8080/worldgdp/api/countries in the browser to see the following input:

bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY