Hands-on Application Development using Spring Boot
eBook - ePub

Hands-on Application Development using Spring Boot

Building Modern Cloud Native Applications by Learning RESTFul API, Microservices, CRUD Operations, Unit Testing, and Deployment

Shagun Bakliwal

Buch teilen
  1. English
  2. ePUB (handyfreundlich)
  3. Über iOS und Android verfügbar
eBook - ePub

Hands-on Application Development using Spring Boot

Building Modern Cloud Native Applications by Learning RESTFul API, Microservices, CRUD Operations, Unit Testing, and Deployment

Shagun Bakliwal

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

A pragmatic guide for Java developers to help build Microservices and Cloud Apps using Spring Boot.

Key Features
? Develops microservices from start to finish using the Spring Boot Framework.
? Creates cloud-native applications using Spring Boot's production-ready features.
? Covers the API gateway, unit testing, cloud deployments, and managing high-traffic applications.

Description
Spring is an excellent framework for developing both web and cloud-native applications. This book on application development using Spring Boot simplifies the process of writing boilerplate code for complex software. It allows developers to concentrate on the application's concept rather than on the internal Java configuration.This book will guide you on how to make the best use of the strength that Spring Boot provides. You'll gain an understanding of how Spring Boot configuration works in conjunction with application development, including auto-configuration and overriding default configurations. You will learn to develop scalable, dependable microservices to accelerate the development lifecycle of a cloud-based application. Each chapter will walk you through the features of Spring Boot as a Software Development Framework, such as performing Create, Read, Update, and Delete (CRUD) operations on a database and securing web services with appropriate logging.By the end of this book, you will develop, test, and deploy applications ready for production and how to establish them as cloud-based applications. The readers will also gain the expertise of writing unit and integration test cases.

What you will learn
? Get to know Spring Boot and all its capabilities.
? Build start-to-end production-ready applications.
? Explore the API Gateway and practice how to run request routing.
? Learn API doc tools like Swagger and host your apps on Cloud.
? Practice how to balance the application's load when the system is under high traffic.
? Learn to write unit tests and integration tests for bug-free coding.

Who this book is for
This book is for Java developers who want to quickly develop, test, and deploy production-ready applications. This book will also appeal to cloud-native application developers and cloud engineers. No prior Spring Boot knowledge is required as the basics are covered in the book.

Table of Contents
1. Getting Started with Spring Boot
2. Developing Your First Spring Boot Application
3. Spring Boot Starter Dependencies and Auto-Configuration
4. Spring Boot Annotations
5. Working with Spring Data JPA and Caching
6. Building RESTFul Microservices
7. Securing a Web Application
8. Building Resilient System
9. Logging
10. Working with the Swagger API Management Tool
11. Testing a Spring Boot Application
12. Deploying a Spring Boot Application

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Hands-on Application Development using Spring Boot als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu Hands-on Application Development using Spring Boot von Shagun Bakliwal im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Informatique & Architecture des systèmes. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

CHAPTER 1

Getting Started with Spring Boot

As the web application development has changed from Java Server Pages (JSPs), Servlets to Spring, many problems of the boiler plate code have reduced. Spring has really reduced the boilerplate code to an extent. The Spring team has developed Spring Boot on the top of the Spring framework that eliminated boilerplate configurations required for Spring applications. This chapter will introduce you to the Spring Boot Framework with the latest version 2.4.3. It will cover the basics of setting up the Spring Boot workspace with tools like JDK 8, Spring Tool Suite (STS), Spring Initializr, and Apache Maven and Gradle as build tools.

Structure

In this chapter, we will discuss the following topics:
  • Introduction to Spring Boot
  • Features of Spring Boot
  • Advantages of Spring Boot
  • Breaking the monolithic way of developing software
  • When to start using microservices?
  • When not to start using microservices?
  • System requirements
  • Setting up the environment
  • The 12-factor app
  • Spring Initializr

Objectives

After studying this unit, you should be able to understand the concept of Spring Boot. You can set up your development environment and learn the 12-factor app that an application should have.

Introduction to Spring Boot

On October 17, 2012, Mike Youngstrom opened a JIRA ticket with the Spring framework team asking for the support for container less web application architectures. As the developers would be more interested in adopting a simpler framework, there should be a mechanism that would allow the developers not to remember both configurations for the Spring model as well as the servlet container on which they are executing their application. There were few items within the older architecture of Spring core that was configured in an inconsistent non-unified way that the developers have to first learn the servlet container on which they are going to deploy in addition to the Spring’s own configuration model.
He proposed an idea for having the servlet container and related tools as a part of the Spring component by embedding and unifying the configuration of those common web container services with the Spring container that can be bootstrapped from the main() method.
This issue was addressed by Phil Webb and from there the Spring Boot started evolving in 2013. On April 1, 2014, the first Spring Boot 1.0 Globally Available (GA) was released which addressed the preceding concern in addition to the issues.
Spring Boot is now an open-source Java-based framework used to create standalone microservices with production-ready features. It is heavily maintained by the Pivotal Team. Microservices is an architectural design that creates scalable, loosely coupled, and testable applications which have a single function module with well-defined interfaces. The microservices hence created by using Spring Boot can be owned and maintained by a small team; unlike it used to be while creating APIs by older technologies like Java web services that required a team of a larger size. This microservice design is adapted by many enterprises in recent years as they look to have their software development delivery in the Agile manner where they can continuously develop, test, and deliver.

Features of Spring Boot

Why the Spring team developed Spring Boot? How is it beneficial for developers to build their application on Spring Boot and not Spring? How are configurations managed? All features of Spring Boot would be explained in this and upcoming chapters. Few of them are listed as follows:
  • Faster way of developing applications by reducing the boilerplate configurations.
  • Loosely coupled dependencies.
  • Starter packs available as part of dependency for simplifying builds and configuration.
  • Creating production-ready microservices with actuator health endpoints such as health, httptrace, mappings, metrics, info, configprops, env, and so on.
  • Embedded container server support. By default, Tomcat is used.
  • Auto-configuration for dependencies; once the dependency is loaded into the class path, Spring Boot manages the class instantiations, when needed.
  • Externalized configurations with the help of .properties and .yml files and Spring Cloud Config.
  • Live reload for the application during the development phase.
  • Ability to exclude/change the dependency version before deployment.

Advantages of Spring Boot

Spring Boot helps you to create stand-alone Spring-based applications with production-ready features that you can execute on the local workspace and the cloud platform which has the Java Virtual Machine (JVM) installed. By using Spring Boot as the development platform, you can get started with the creation of an application with minimum code setup with less development time, so that the focus will be in contract with the features that you want to imply in the application. This allows the developer to focus on the idea that evolves during the initial phase of the requirement and then it is the magic of Spring Boot that helps you to bootstrap your application, its external dependencies on the resources like accessing the database and managing the external calls to other applications that consume the data in the prescribed format. Mostly, Spring Boot applications need less Spring configuration.
After you build your Spring Boot application, it can be executed by java –jar <jar name> just like any other Java project that builds a jar file. The Spring Boot application can also be started by running the mvn spring-boot:run command on the root directory which contains the src folder.

Breaking the monolithic way of developing software

Since years the software development used to happen in a monolithic architecture. The developer or the business analyst or even the product owner of the software receives a big requirement at once and then after getting the details of the requirements, the team starts to work on. This leads to the waterfall model of developing a software which is good to release a Minimal Viable Product (MVP) that is a single release to showcase about what the product is. This single release is created in a single application containing all codes to resolve the user problem. Problem arises when the requirements are portrayed in such a way that the code already developed is duplicated to fulfill another requirement, that is, chunks of code can be repeated which leads to bad quality of code.
Now imagine for that requirement, all we need to repeat all sorts of regression and stress testing which was already done previously before releasing the product. Why should all codes be tested even if that single enhancement may not be related to test the whole application?
Since then, business capabilities are delivered using microservices. Now, selecting the microservice architecture over the monolithic architecture can have many reasons and may not be limited to the features of microservices as follows:
  • Each service can have a single functionality, single data repository.
  • Each service is in...

Inhaltsverzeichnis