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

Compartir libro
  1. English
  2. ePUB (apto para móviles)
  3. Disponible en iOS y Android
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

Detalles del libro
Vista previa del libro
Índice
Citas

Información del libro

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

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es Hands-on Application Development using Spring Boot un PDF/ePUB en línea?
Sí, puedes acceder a Hands-on Application Development using Spring Boot de Shagun Bakliwal en formato PDF o ePUB, así como a otros libros populares de Informatique y Architecture des systèmes. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Año
2021
ISBN
9789391030223

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...

Índice