(FREE PDF Sample) Pro Spring MVC With WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 2nd Edition Marten Deinum Ebooks
(FREE PDF Sample) Pro Spring MVC With WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 2nd Edition Marten Deinum Ebooks
com
https://textbookfull.com/product/pro-spring-mvc-with-
webflux-web-development-in-spring-framework-5-and-spring-
boot-2-2nd-edition-marten-deinum/
OR CLICK BUTTON
DOWNLOAD NOW
https://textbookfull.com/product/pro-spring-mvc-with-webflux-web-
development-in-spring-framework-5-and-spring-boot-2-2nd-edition-
marten-deinum-2/
textboxfull.com
https://textbookfull.com/product/pro-spring-security-securing-spring-
framework-5-and-boot-2-based-java-applications-2nd-edition-carlo-
scarioni/
textboxfull.com
https://textbookfull.com/product/spring-5-recipes-a-problem-solution-
approach-4th-edition-marten-deinum/
textboxfull.com
Pro Spring 5: an in-depth guide to the Spring framework
and its tools Cosmina
https://textbookfull.com/product/pro-spring-5-an-in-depth-guide-to-
the-spring-framework-and-its-tools-cosmina/
textboxfull.com
https://textbookfull.com/product/spring-quick-reference-guide-a-
pocket-handbook-for-spring-framework-spring-boot-and-more-adam-l-
davis/
textboxfull.com
Marten Deinum
Iuliana Cosmina
Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and
Spring Boot 2
Marten Deinum Iuliana Cosmina
MEPPEL, Drenthe, The Netherlands EDINBURGH, UK
v
Table of Contents
Web Applications������������������������������������������������������������������������������������������������������������������������� 47
Spring Boot��������������������������������������������������������������������������������������������������������������������������������� 52
Summary������������������������������������������������������������������������������������������������������������������������������������ 54
vi
Table of Contents
RequestToViewNameTranslator������������������������������������������������������������������������������������������� 118
ViewResolver����������������������������������������������������������������������������������������������������������������������� 119
FlashMapManager��������������������������������������������������������������������������������������������������������������� 121
Summary���������������������������������������������������������������������������������������������������������������������������������� 122
vii
Table of Contents
viii
Table of Contents
ix
Table of Contents
x
Table of Contents
Index��������������������������������������������������������������������������������������������������������������������� 563
xi
About the Authors
Marten Deinum is a submitter on the open source Spring Framework project. He is also
a Java/software consultant working for Conspect. He has developed and architected
software, primarily in Java, for small and large companies. He is an enthusiastic open
source user and a longtime fan, user, and advocate of the Spring Framework. His work
experience includes being a software engineer, development lead, coach, and a Java
and Spring trainer. When not working on software, he can be found near or in the water
scuba diving or teaching scuba diving.
xiii
About the Technical Reviewer
Manuel Jordan Elera is an autodidactic developer and
researcher who enjoys learning new technologies for
his own experiments and creating new integrations.
Manuel won the Springy Award—Community Champion and
Spring Champion 2013. In his free time, he reads the Bible
and composes music on his guitar. Manuel is known as
dr_pompeii. He has tech-reviewed numerous books for
Apress, including Pro Spring Boot 2 (2019), Rapid Java
Persistence and Microservices (2019), Java Language
Features (2018), Spring Boot 2 Recipes (2018), and Java APIs,
Extensions, and Libraries (2018). You can read his 13 detailed tutorials about Spring
technologies, or contact him, through his blog at www.manueljordanelera.blogspot.com,
and follow him on his Twitter account, @dr_pompeii.
xv
Acknowledgments
I would like to say thank you to Mark Powers. He has been with me since the time I
began collaborating with Apress, and I consider him my project manager at Apress.
When writing a book, he is the one that I agree schedules and deadlines with and
then say sorry to when I am unable to deliver as agreed. He has been supportive and
understanding and one of the people I respect the most. Most of my books, including
this one, happened because he was there to make sure I didn’t postpone the work too
long because of writer’s block or my imposter syndrome.
Additionally, a special thanks to Manuel Jordan, the reviewer for all my books
but one—and I missed him a lot when working on that one. I missed his patience, his
attention to detail, and his suggestions on what else should be in a book to be more
valuable. I was happy when I was told he would be joining the team for this book as a
reviewer.
A very heartfelt thanks to Mihaela Filipiuc, who has been my most supportive
remote friend, even while she was going through a tough time. She has provided the
motivational words that I needed to keep my spirits up and push through sleepless
nights to make this book happen.
Another heartfelt thanks to my dear friend Mihai Fat for all the inspiring technical chats.
An additional thanks to my team at Cloudsoft for being patient with me when I was
working while sleep deprived and for all the moral support during these tough times.
Having a full-time job and writing a book during a pandemic that has kept me away from
my friends and family would have been way more difficult without them. Thank you
for being the best environment in which I can continue to learn and grow as a software
developer.
— Iuliana Cosmina
xvii
CHAPTER 1
Setting up a Local
Development Environment
Released in October 2002 as an open source framework and inversion of control (IoC)
container developed using Java, Spring was built for the Java platform. It has transformed
from a small collection of libraries into a huge collection of full-blown projects designed
to simplify development even when the solution is complex.
This book journeys from a classic web application packaged as a jar and deployed to
an application server to an application composed of a set of microservices that are easily
deployed in a cloud environment, each of them on its own VM or container.
It all starts with a set of tools that need to be installed before the developer can write
and run code.
If you know how to use SDKMAN,1 you can skip the next two sections that
explain how to install the Java SDK and Gradle. If you do not know how to use
SDKMAN or never knew it existed, give it a try; it is a tool for managing parallel
versions of multiple SDKs. If you have other projects using different versions
of Java and Gradle locally, this tool helps you switch between them without
a fuss.
1
https://sdkman.io/
1
© Marten Deinum and Iuliana Cosmina 2021
M. Deinum and I. Cosmina, Pro Spring MVC with WebFlux, https://doi.org/10.1007/978-1-4842-5666-4_1
Chapter 1 Setting up a Local Development Environment
Restart the terminal and verify that the version of Java the operating system sees is
the one that you installed by opening a terminal (the Command prompt in Windows or
any type of terminal installed on macOS and Linux) and type the following.
2
h ttps://adoptopenjdk.net/
3
Image source: https://www.programmableweb.com
2
Chapter 1 Setting up a Local Development Environment
> java -version
java version "14.0.2" 2020-07-14
Java(TM) SE Runtime Environment (build 14.0.2+12-46)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)
> javac -version
javac 14.0.2
I nstall Gradle
Gradle is an open source build automation tool designed to be flexible enough to build
almost any type of software. It uses Groovy in its configuration files, which makes it
customizable. The project attached to this book was successfully built with Gradle 6.x.
The sources attached to this book can be compiled and executed using the Gradle
Wrapper, which is a batch script on Windows and a shell script on other operating
systems.
When you start a Gradle build via the wrapper, Gradle is automatically downloaded
inside your project to run the build; thus, you do not need to explicitly install it on your
system. The recommended editor for development introduced next knows how to build
code using Gradle Wrapper. Instructions on how to use the Gradle Wrapper are available
in the public documentation at www.gradle.org/docs/current/userguide/gradle_
wrapper.html.
A recommended practice is to keep the code and build tools separately. If you decide to
install Gradle on your system, you can download the binaries from www.gradle.org, unpack
it and copy the contents to the hard drive. (Or, if you are curious, you can download the
full package containing binaries, sources, and documentation.) Create a GRADLE_HOME
4
Image source: https://www.gradle.org
3
Chapter 1 Setting up a Local Development Environment
environment variable and point it to the location where you unpacked Gradle. Also, add
$GRADLE_HOME/bin (%GRADLE_HOME%\bin for Windows users) to the system’s general path
so that you can build the project in a terminal.
Gradle was chosen as a build tool for this book’s sources because of the easy setup,
small configuration files, flexibility in defining execution tasks, and the Spring team
currently uses it to build all Spring projects.
To verify that the operating system sees the Gradle version that you just installed,
open a terminal (the Command prompt in Windows, and any type of terminal installed
on macOS and Linux) and type
gradle -version
gradle -version
------------------------------------------------------------
Gradle 6.7
------------------------------------------------------------
Kotlin: 1.3.72
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM: 14.0.2 (Oracle Corporation 14.0.2+12-46)
OS: Mac OS X 10.15.6 x86_64
Running this command also verifies that Gradle is using the intended JDK version.
4
Chapter 1 Setting up a Local Development Environment
The Spring MVC projects of this book were tested in Apache Tomcat 9.x. To install
Apache Tomcat, go to the official site and get the version matching your operating
system. Unpack it in a familiar location. On Unix-based systems, you might be able to
install it using a package manager. If you install it manually, remember to go to the bin
directory and make all files executable.
5
h ttps://tomcat.apache.org/
6
Image source: https://tomcat.apache.org
5
Chapter 1 Setting up a Local Development Environment
R
ecommended IDE
The IDE that we recommend you use with the code in this book is IntelliJ IDEA. It is the
most intelligent Java IDE.
7
Image source: https://www.jetbrains.com/idea/
6
Chapter 1 Setting up a Local Development Environment
7
Chapter 1 Setting up a Local Development Environment
8
Chapter 1 Setting up a Local Development Environment
B
uilding the Project
Once you’ve installed the recommended tools, the next step is getting the project sources
from GitHub.
You can download the repo page sources, clone the project using IntelliJ IDEA, or
clone it using Git in the terminal. You can use HTTPS or Git protocol—whatever feels
familiar and easy.
You can build the project using IntelliJ IDEA, but if you are opening it for the
first time, it takes a while to figure out the project structure and index the files. We
recommend that you open a terminal and build the project by executing the command
in Listing 1-1. The output should be similar to that one, and it must certainly contain
BUILD SUCCESSFUL.
Once the project builds in the terminal, you can verify that you have the right project
and the right tools. It is now time to open it in IntelliJ IDEA.
The first thing you notice is that IntelliJ IDEA is trying to decide the Gradle and the
JDK versions. And it doesn’t always work, especially if you have multiple versions of each
on your system. In the right corner, you might see notifications like the one in Figure 1-5.
9
Chapter 1 Setting up a Local Development Environment
Figure 1-5. IntelliJ IDEA trying to infer Gradle and JDK version
1. First, if you want to use Gradle Wrapper, skip this step. Otherwise,
go to the Gradle view, click the little wrench button (the one
labeled Build Tool Settings), and a window appears to allow you
to choose the Gradle version. If you have Gradle installed on your
system, and the GRADLE_HOME environment variable is set up,
IntelliJ IDEA finds it. Still, it does not use it if the project contains
a Gradle Wrapper configuration. To use Gradle on your system,
choose Specified location in the section of the window marked in
Figure 1-6.
10
Chapter 1 Setting up a Local Development Environment
And, while you’re at it, make sure the Gradle JVM is set to JDK 14
as well.
2. In the IntelliJ IDEA main menu, select File > Project structure…
. The Project Structure window allows you to configure the project
SDK and the project language level. Make sure it is JDK 14 for
both, as depicted in Figure 1-7.
11
Chapter 1 Setting up a Local Development Environment
If all goes well, IntelliJ IDEA uses Gradle and JDK to build your project and execute
tests. If you want to build your project in IntelliJ IDEA, use the Gradle View. When the
project is loaded correctly, all modules should be listed together with a set of Gradle
tasks grouped by their purpose. Under the build group, a task named build is the
equivalent of the Gradle command in Listing 1-1. Figure 1-8 shows a successful Gradle
build run in IntelliJ IDEA.
12
Chapter 1 Setting up a Local Development Environment
R
unning the Projects
The projects that are not built using Spring Boot need to be deployed to an Apache
Tomcat server. After a successful Gradle build, the artifacts should be already generated
for all projects. To deploy your project on your local Apache server, you must do the
following.
1. Click the list of project launchers in the upper-right corner.
2. Select Edit Configurations….
3. In the Edit Configurations window, select the type of launcher that
you want to create.
4. In the upper-left corner, click the + button. In the list of launcher
types, select Tomcat Server > Local (see Figure 1-9).
13
Chapter 1 Setting up a Local Development Environment
9. Click the Fix button. You are warned that you must select
something to deploy (see Figure 1-10).
14
Chapter 1 Setting up a Local Development Environment
Figure 1-10. IntelliJ IDEA Launcher options for configuring Apache Tomcat server
and artifact to deploy
10. In the list, select the project that you want to deploy.
11. Next, in the Deployment tab, you can edit the context path
because the autogenerated one is weird.
12. Click the OK button, and you are done (see Figure 1-11).
15
Random documents with unrelated
content Scribd suggests to you:
The Project Gutenberg eBook of The doctor, &c.,
vol. 6 (of 7)
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.
Language: English
BUTLER'S REMAINS.
THE DOCTOR,
&c.
VOL. VI.
LONDON:
LONDON:
PREFACE.
The present Volume is drawn up from the MS. materials alluded to,
as nearly as possible in the order the Author had intended, and the
seventh and concluding volume is in the press and will shortly be
published.
The whole of the MS. sheets, previous to being sent to the press,
were cautiously examined by his no less amiable and excellent, than
highly gifted Widow, who, at the time, was staying with us on a visit
at West-Tarring. Had the lamented Southey continued the work, it
was his intention, in this volume, to have advanced a step in the
story,—and the Interchapters, no doubt, would have been enlarged,
according to custom. His habit was, as he said, “to lay the timbers of
them, and to jot down, from time to time, remarks serious or jocose,
as they occurred to him.” Full readily would this holy and humble
man of heart have acceded to the truth conveyed in these lines from
Martin Tupper's Proverbial philosophy,—and none the less for their
dactylic cadence.
There is a grave-faced folly, and verily a laughter loving wisdom;
And what, if surface judges, account it vain frivolity?
There is indeed an evil in excess, and a field may lie fallow too long;
Yet merriment is often as a froth, that mantleth on the strong mind:
And note thou this for a verity,—the subtlest thinker when alone,
From ease of thoughts unbent, will laugh the loudest with his fellows:
And well is the loveliness of wisdom mirrored in a cheerful countenance,
Justly the deepest pools are proved by dimpling eddies;
For that, a true philosophy commandeth an innocent life,
And the unguilty spirit is lighter than a linnet's heart;
Yea, there is no cosmetic like a holy conscience;
The eye is bright with trust, the cheek bloomed over with affection,
The brow unwrinkled with a care, and the lip triumphant in its gladness.1
The only liberty taken with the original MS. is the omission of, now
and then a name, or even a paragraph, which might have given pain
to the living. Such passages were thrown off playfully, and were, as
Mrs. Southey can testify, erased by the author continually. It was no
custom of Southey to cast “fire-brands, arrows, and death,” and to
say, “Am I not in sport?” (Proverbs, xxvi. 18, 19.)
It only remains to add that the Editor has carefully verified all
references,—that he is responsible for the headings of the chapters
(some few excepted,)—for the Mottoes to cc. clxxx. and clxxxi.,—
and for the casual foot notes.
Vicarage House,
West-Tarring, Nov. 25th.
PRELUDE OF MOTTOES.
HOOKER.
Be rather wise than witty, for much wit hath commonly much froth;
and 'tis hard to jest and not sometimes jeer too; which many times
sinks deeper than was intended or expected; and what was
designed for mirth, ends in sadness.
CALEB TRENCHFIELD.
(probably a fictitious name.) RESTITUTA.
COWPER.
LA NOUE.
Authors, you know of greatest fame,
Thro' modesty suppress their name;
And would you wish me to reveal
What these superior wits conceal?
Forego the search, my curious friend,
And husband time to better end.
All my ambition is, I own,
To profit and to please unknown,
Like streams supplied from springs below
Which scatter blessings as they flow.
DR. COTTON.
ADAM LITTLETON.
ALEXANDER KNOX.
Yea—but what am I?
A scholar, or a schoolmaster, or else some youth?
A lawyer, a student, or else a country clown?
A brumman, a basket-maker, or a baker of pies?
A flesh, or a fishmonger, or a sower of lies?
A louse, or a louser, a leek or a lark,
A dreamer, a drommell, a fire or a spark?
A caitiff, a cut-throat, a creeper in corners,
A hairbrain, a hangman, or a grafter of horners?
A merchant, a maypole, a man or a mackarel,
A crab or a crevise, a crane or a cockerell?
APIUS AND VIRGINIA.
Etsi verò, quæ in isto opere desiderentur, rectiùs forsan quàm quivis
alius, perspiciam; et si meo planè voto standum fuisset, id, in tantâ,
quæ hodie est librorum copiâ, vel planè suppressissem, vel in multos
annos adhuc pressissem; tamen aliquid amicis, aliquid tempori
dandum; et cum iis qui aliquid fructus ex eo sperant, illud
communicandum putavi. Hunc itaque meum qualemcunque laborem,
Lector candide, boni consule; quod te facilè facturum confido, si eum
animum ad legendum attuleris, quem ego ad scribendum, veritatis
nimirum aliisque inserviendi cupidum.
SENNERTUS.
CONTENTS.
CHAPTER CLXXII.
CLXXIII.
CLXXIV.
THE DOCTOR INDULGES IN THE WAY OF FANTASTIC AND TYPICAL
SPECULATION ON HIS OWN NAME, AND ON THE POWERS OF THE LETTER D.,
WHETHER AS REGARDS DEGREES AND DISTINCTIONS, GODS AND
DEMIGODS, PRINCES AND KINGS, PHILOSOPHERS, GENERALS OR
TRAVELLERS.
QUARLES.
CHAPTER CLXXV.
More authority dear boy, name more; and sweet my child let them be men of good
repute and carriage.—
CHAPTER CLXXVI.
An I take the humour of a thing once, I am like your tailor's needle; I go through.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com