100% found this document useful (1 vote)
236 views55 pages

(FREE PDF Sample) Pro Spring MVC With WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 2nd Edition Marten Deinum Ebooks

Web

Uploaded by

sakissimhac2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
236 views55 pages

(FREE PDF Sample) Pro Spring MVC With WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 2nd Edition Marten Deinum Ebooks

Web

Uploaded by

sakissimhac2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Download the Full Version of textbook for Fast Typing at textbookfull.

com

Pro Spring MVC with WebFlux: Web Development in


Spring Framework 5 and Spring Boot 2 2nd Edition
Marten Deinum

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

Download More textbook Instantly Today - Get Yours Now at textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Pro Spring MVC with WebFlux: Web Development in Spring


Framework 5 and Spring Boot 2 2nd Edition Marten Deinum

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

Pro Spring MVC with WebFlux Web Development in Spring


Framework 5 and Spring Boot 2 Second Edition Marten Deinum
Iuliana Cosmina
https://textbookfull.com/product/pro-spring-mvc-with-webflux-web-
development-in-spring-framework-5-and-spring-boot-2-second-edition-
marten-deinum-iuliana-cosmina/
textboxfull.com

Pro Spring Security: Securing Spring Framework 5 and Boot


2-based Java Applications 2nd Edition Carlo Scarioni

https://textbookfull.com/product/pro-spring-security-securing-spring-
framework-5-and-boot-2-based-java-applications-2nd-edition-carlo-
scarioni/
textboxfull.com

Spring 5 Recipes: A Problem-Solution Approach 4th Edition


Marten Deinum

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

Spring Quick Reference Guide: A Pocket Handbook for Spring


Framework, Spring Boot, and More Adam L. Davis

https://textbookfull.com/product/spring-quick-reference-guide-a-
pocket-handbook-for-spring-framework-spring-boot-and-more-adam-l-
davis/
textboxfull.com

Spring Boot 2 0 Projects Build production grade reactive


applications and microservices with Spring Boot English
Edition Mohamed Shazin Sadakath
https://textbookfull.com/product/spring-boot-2-0-projects-build-
production-grade-reactive-applications-and-microservices-with-spring-
boot-english-edition-mohamed-shazin-sadakath/
textboxfull.com

Pro Spring Boot 2: An Authoritative Guide to Building


Microservices, Web and Enterprise Applications, and Best
Practices 2nd Edition Felipe Gutierrez
https://textbookfull.com/product/pro-spring-boot-2-an-authoritative-
guide-to-building-microservices-web-and-enterprise-applications-and-
best-practices-2nd-edition-felipe-gutierrez/
textboxfull.com

Practical Microservices Architectural Patterns: Event-


Based Java Microservices with Spring Boot and Spring Cloud
Christudas
https://textbookfull.com/product/practical-microservices-
architectural-patterns-event-based-java-microservices-with-spring-
boot-and-spring-cloud-christudas/
textboxfull.com
Pro Spring MVC
with WebFlux
Web Development in Spring Framework 5
and Spring Boot 2

Second Edition

Marten Deinum
Iuliana Cosmina
Pro Spring MVC
with WebFlux
Web Development in Spring
Framework 5 and Spring Boot 2
Second Edition

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

ISBN-13 (pbk): 978-1-4842-5665-7 ISBN-13 (electronic): 978-1-4842-5666-4


https://doi.org/10.1007/978-1-4842-5666-4

Copyright © 2021 by Marten Deinum and Iuliana Cosmina


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Steve Anglin
Development Editor: Matthew Moodie
Coordinating Editor: Mark Powers
Cover designed by eStudioCalamar
Cover image by rawpixel (www.rawpixel.com)
Distributed to the book trade worldwide by Apress Media, LLC, 1 New York Plaza, New York, NY 10004,
U.S.A. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.
springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science
+ Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail [email protected]; for reprint,
paperback, or audio rights, please email [email protected].
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/9781484256657. For more
detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
To all of you that have bought other books that I worked on,
this book is dedicated to you.
Thank you for trusting me.
— Iuliana Cosmina
Table of Contents
About the Authors�������������������������������������������������������������������������������������������������� xiii

About the Technical Reviewer���������������������������������������������������������������������������������xv


Acknowledgments�������������������������������������������������������������������������������������������������xvii

Chapter 1: Setting up a Local Development Environment���������������������������������������� 1


Install the Java SDK���������������������������������������������������������������������������������������������������������������������� 2
Install Gradle��������������������������������������������������������������������������������������������������������������������������������� 3
Install Apache Tomcat������������������������������������������������������������������������������������������������������������������� 5
Recommended IDE������������������������������������������������������������������������������������������������������������������������ 6
The Bookstore Project������������������������������������������������������������������������������������������������������������������� 6
Building the Project����������������������������������������������������������������������������������������������������������������� 9
Running the Projects������������������������������������������������������������������������������������������������������������� 13
Summary������������������������������������������������������������������������������������������������������������������������������������ 19

Chapter 2: Spring Framework Fundamentals��������������������������������������������������������� 21


The Spring Framework��������������������������������������������������������������������������������������������������������������� 22
Dependency Injection������������������������������������������������������������������������������������������������������������������ 26
ApplicationContexts�������������������������������������������������������������������������������������������������������������������� 32
Resource Loading������������������������������������������������������������������������������������������������������������������ 37
Component Scanning������������������������������������������������������������������������������������������������������������ 38
Scopes����������������������������������������������������������������������������������������������������������������������������������� 39
Profiles���������������������������������������������������������������������������������������������������������������������������������� 40
Enabling Features������������������������������������������������������������������������������������������������������������������ 44
Aspect-Oriented Programming���������������������������������������������������������������������������������������������� 46

v
Table of Contents

Web Applications������������������������������������������������������������������������������������������������������������������������� 47
Spring Boot��������������������������������������������������������������������������������������������������������������������������������� 52
Summary������������������������������������������������������������������������������������������������������������������������������������ 54

Chapter 3: Web Application Architecture��������������������������������������������������������������� 55


The MVC Pattern������������������������������������������������������������������������������������������������������������������������� 55
Application Layering������������������������������������������������������������������������������������������������������������������� 58
Separation of Concerns��������������������������������������������������������������������������������������������������������������� 61
Spring MVC Application Layers��������������������������������������������������������������������������������������������������� 62
The Domain Layer������������������������������������������������������������������������������������������������������������������ 62
The User Interface Layer������������������������������������������������������������������������������������������������������� 63
The Web Layer����������������������������������������������������������������������������������������������������������������������� 64
The Service Layer������������������������������������������������������������������������������������������������������������������ 66
The Data Access Layer���������������������������������������������������������������������������������������������������������� 69
More Roads to Rome������������������������������������������������������������������������������������������������������������������� 71
Summary������������������������������������������������������������������������������������������������������������������������������������ 72

Chapter 4: Spring MVC Architecture����������������������������������������������������������������������� 73


DispatcherServlet Request Processing Workflow����������������������������������������������������������������������� 73
The Workflow������������������������������������������������������������������������������������������������������������������������� 74
The Request Processing Summary��������������������������������������������������������������������������������������� 82
DispatcherServlet����������������������������������������������������������������������������������������������������������������������� 83
Bootstrapping DispatcherServlet������������������������������������������������������������������������������������������� 84
Configuring DispatcherServlet����������������������������������������������������������������������������������������������� 90
The Spring MVC Components��������������������������������������������������������������������������������������������������� 101
HandlerMapping������������������������������������������������������������������������������������������������������������������ 101
HandlerAdapter������������������������������������������������������������������������������������������������������������������� 107
MultipartResolver���������������������������������������������������������������������������������������������������������������� 110
LocaleResolver�������������������������������������������������������������������������������������������������������������������� 112
ThemeResolver�������������������������������������������������������������������������������������������������������������������� 114
HandlerExceptionResolver��������������������������������������������������������������������������������������������������� 117

vi
Table of Contents

RequestToViewNameTranslator������������������������������������������������������������������������������������������� 118
ViewResolver����������������������������������������������������������������������������������������������������������������������� 119
FlashMapManager��������������������������������������������������������������������������������������������������������������� 121
Summary���������������������������������������������������������������������������������������������������������������������������������� 122

Chapter 5: Implementing Controllers������������������������������������������������������������������� 123


Introducing Controllers������������������������������������������������������������������������������������������������������������� 123
Interface-based Controllers������������������������������������������������������������������������������������������������� 124
Annotation-based Controllers���������������������������������������������������������������������������������������������� 126
Configuring View Controllers����������������������������������������������������������������������������������������������� 127
Request-Handling Methods������������������������������������������������������������������������������������������������������ 129
Supported Method Argument Types������������������������������������������������������������������������������������ 133
Supported Method Argument Annotations��������������������������������������������������������������������������� 138
Supported Method Return Values���������������������������������������������������������������������������������������� 146
Writing Annotation-based Controllers��������������������������������������������������������������������������������������� 148
A Simple Login Controller���������������������������������������������������������������������������������������������������� 149
Book Search Page��������������������������������������������������������������������������������������������������������������� 155
Book Detail Page����������������������������������������������������������������������������������������������������������������� 160
Data Binding����������������������������������������������������������������������������������������������������������������������������� 164
Customizing Data Binding��������������������������������������������������������������������������������������������������� 165
Per Controller Customization����������������������������������������������������������������������������������������������� 167
ModelAttributes������������������������������������������������������������������������������������������������������������������� 170
Type Conversion������������������������������������������������������������������������������������������������������������������ 178
Validating Model Attributes������������������������������������������������������������������������������������������������� 195
Internationalization������������������������������������������������������������������������������������������������������������������� 204
Message Source������������������������������������������������������������������������������������������������������������������ 204
LocaleResolver�������������������������������������������������������������������������������������������������������������������� 206
LocaleChangeInterceptor���������������������������������������������������������������������������������������������������� 207
Summary���������������������������������������������������������������������������������������������������������������������������������� 212

vii
Table of Contents

Chapter 6: Implementing Controllers: Advanced�������������������������������������������������� 213


Using Scoped Beans����������������������������������������������������������������������������������������������������������������� 213
Adding Something to the Cart��������������������������������������������������������������������������������������������� 215
Implementing the Checkout������������������������������������������������������������������������������������������������ 218
Cross-cutting Concerns������������������������������������������������������������������������������������������������������������ 222
Interceptors������������������������������������������������������������������������������������������������������������������������� 222
Exception Handling�������������������������������������������������������������������������������������������������������������� 236
SimpleMappingExceptionResolver�������������������������������������������������������������������������������������� 241
Extending Spring @MVC����������������������������������������������������������������������������������������������������������� 246
Extending RequestMappingHandlerMapping����������������������������������������������������������������� 246
Extending the RequestMappingHandlerAdapter������������������������������������������������������������������ 248
Using the RequestDataValueProcessor������������������������������������������������������������������������������� 255
Summary���������������������������������������������������������������������������������������������������������������������������������� 257

Chapter 7: REST and AJAX������������������������������������������������������������������������������������ 259


REpresentational State Transfer (REST)������������������������������������������������������������������������������������ 259
Identifying Resources���������������������������������������������������������������������������������������������������������� 260
Working with Resources������������������������������������������������������������������������������������������������������ 260
Asynchronous JavaScript and XML (AJAX)������������������������������������������������������������������������������� 264
Adding AJAX to Our Application������������������������������������������������������������������������������������������� 266
Combining AJAX and REST�������������������������������������������������������������������������������������������������� 273
Progressive Enhancement��������������������������������������������������������������������������������������������������� 274
Handling File Uploads��������������������������������������������������������������������������������������������������������������� 275
Configuration����������������������������������������������������������������������������������������������������������������������� 276
Request Handling Method for File Upload��������������������������������������������������������������������������� 278
Exception Handling�������������������������������������������������������������������������������������������������������������� 284
Summary���������������������������������������������������������������������������������������������������������������������������������� 284

viii
Table of Contents

Chapter 8: Resolving and Implementing Views���������������������������������������������������� 285


View Resolvers and Views�������������������������������������������������������������������������������������������������������� 285
View Resolvers�������������������������������������������������������������������������������������������������������������������������� 287
BeanNameViewResolver����������������������������������������������������������������������������������������������������� 288
UrlBasedViewResolver��������������������������������������������������������������������������������������������������������� 289
InternalResourceViewResolver�������������������������������������������������������������������������������������������� 292
XsltViewResolver����������������������������������������������������������������������������������������������������������������� 293
ContentNegotiatingViewResolver���������������������������������������������������������������������������������������� 293
Implementing Your Own ViewResolver�������������������������������������������������������������������������������� 295
View Technologies��������������������������������������������������������������������������������������������������������������������� 295
JavaServer Pages���������������������������������������������������������������������������������������������������������������� 296
Tiles������������������������������������������������������������������������������������������������������������������������������������� 297
FreeMarker and Thymeleaf�������������������������������������������������������������������������������������������������� 304
PDF�������������������������������������������������������������������������������������������������������������������������������������� 318
Excel������������������������������������������������������������������������������������������������������������������������������������ 321
XML and JSON��������������������������������������������������������������������������������������������������������������������� 325
Summary���������������������������������������������������������������������������������������������������������������������������������� 327

Chapter 9: Introduction to Spring WebFlux���������������������������������������������������������� 329


HTTP Request Handling������������������������������������������������������������������������������������������������������������ 330
Building Reactive Applications�������������������������������������������������������������������������������������������������� 333
Introduction to Reactive Programming�������������������������������������������������������������������������������� 333
Introduction to Spring WebFlux������������������������������������������������������������������������������������������������� 347
Spring WebFlux Configuration: Reactive Controllers����������������������������������������������������������� 348
Spring WebFlux Configuration: Functional Endpoints���������������������������������������������������������� 360
Summary���������������������������������������������������������������������������������������������������������������������������������� 366

Chapter 10: Building Reactive Applications with Spring WebFlux����������������������� 369


From Spring Web MVC to Spring WebFlux�������������������������������������������������������������������������������� 369
Migrating the Data Access Layer����������������������������������������������������������������������������������������� 370
Migrating the Service Layer������������������������������������������������������������������������������������������������ 373

ix
Table of Contents

Migrating the Web Layer����������������������������������������������������������������������������������������������������������� 375


Configuration of a Reactive Templating Engine������������������������������������������������������������������� 375
Using Server-Sent Events (SSEs)����������������������������������������������������������������������������������������� 382
Introducing WebClient and WebTestClient��������������������������������������������������������������������������� 392
Internationalization�������������������������������������������������������������������������������������������������������������� 401
Validation, Type Conversion, and Error Handling����������������������������������������������������������������� 408
Summary���������������������������������������������������������������������������������������������������������������������������������� 420

Chapter 11: Securing Spring WebFlux Applications��������������������������������������������� 421


Backpressure���������������������������������������������������������������������������������������������������������������������������� 421
The WebSocket Protocol������������������������������������������������������������������������������������������������������ 422
Handling Backpressure������������������������������������������������������������������������������������������������������� 439
The RSocket Protocol���������������������������������������������������������������������������������������������������������� 445
WebFlux Security���������������������������������������������������������������������������������������������������������������������� 456
Summary���������������������������������������������������������������������������������������������������������������������������������� 469

Chapter 12: Spring Security��������������������������������������������������������������������������������� 471


Security Basics������������������������������������������������������������������������������������������������������������������������� 472
Minimal Spring Web Security���������������������������������������������������������������������������������������������������� 473
Using Spring Security��������������������������������������������������������������������������������������������������������������� 476
Configuring Authentication�������������������������������������������������������������������������������������������������� 481
Configuring Authorization���������������������������������������������������������������������������������������������������� 490
Configure Login and Logout������������������������������������������������������������������������������������������������ 500
Securing Methods��������������������������������������������������������������������������������������������������������������� 512
Securing Spring Boot Web Applications������������������������������������������������������������������������������������ 518
Summary���������������������������������������������������������������������������������������������������������������������������������� 519

Chapter 13: Spring Applications in the Cloud������������������������������������������������������� 521


Application Architecture������������������������������������������������������������������������������������������������������������ 521
Introducing the Monolith����������������������������������������������������������������������������������������������������� 521
Introducing Microservices��������������������������������������������������������������������������������������������������� 524
Moving to the Cloud: Yea or Nay?���������������������������������������������������������������������������������������� 527

x
Table of Contents

Introducing Spring Cloud����������������������������������������������������������������������������������������������������� 529


Redesigning for the Cloud��������������������������������������������������������������������������������������������������� 530
Registration and Discovery Server�������������������������������������������������������������������������������������� 532
Developing a Microservice�������������������������������������������������������������������������������������������������� 537
Microservice Using a Database������������������������������������������������������������������������������������������� 547
Microservice with a Web Console��������������������������������������������������������������������������������������� 550
Sharing Classes������������������������������������������������������������������������������������������������������������������� 560
Summary���������������������������������������������������������������������������������������������������������������������������������� 561

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.

Iuliana Cosmina is currently a software engineer for


Cloudsoft in Edinburgh, Scotland. She has been writing Java
code since 2002. She has contributed to various types of
applications, including experimental search engines, ERPs,
track and trace, and banking. During her career, she has
been a teacher, a team leader, a software architect, a DevOps
professional, and a software manager. She is a Spring
Certified Professional, as defined by Pivotal, the makers of
Spring Framework, Boot, and other tools, and considers
Spring the best Java framework to work with.
When she is not programming, she spends her time
reading, blogging, learning to play piano, traveling, hiking,
or biking.

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

Install the Java SDK


Since Spring is a Java framework to write and run Spring applications, you need to install
the Java SDK. This project was written and built with JDK 14. To install JDK 14, download
the JDK matching your operating system from www.oracle.com/java/ and install it. So, if
you are building an application and intend to use it for financial gain, you might want to
look at Oracle licensing or use an open source JDK.2

Figure 1-1. The Java logo3

We recommend that you set the JAVA_HOME environment variable to point to


the directory where Java 14 was installed (the directory in which the JDK was
unpacked) and add $JAVA_HOME/bin (%JAVA_HOME%\bin for Windows users)
to the general path of the system. The reason behind this is to ensure any other
development application written in Java use this version of Java and prevent
strange incompatibility errors during development. If you want to run the build from
a terminal, you are certain that the expected version of Java is used.

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.

> java -version  # to check the runtime

And then the following.

> javac -version # to check the compiler

2
h ttps://adoptopenjdk.net/
3
Image source: https://www.programmableweb.com

2
Chapter 1 Setting up a Local Development Environment

You should see an output similar to the following.

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

Figure 1-2. The Gradle logo4

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

You should see something similar to the following.

gradle -version

------------------------------------------------------------
Gradle 6.7
------------------------------------------------------------

Build time:   2020-08-04 22:01:06 UTC


Revision:     00a2948da9ea69c523b6b094331593e6be6d92bc

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

Install Apache Tomcat


Web applications are meant to be hosted by an application server unless they are built
using Spring Boot, in which case it is more practical to rely on an embedded server.
Apache Tomcat5 is an open source implementation of the Java Servlet, JavaServer Pages,
Java Expression Language, and WebSocket technologies.

Figure 1-3. The Apache Tomcat logo6

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.

Figure 1-4. The IntelliJ IDEA logo7

IntelliJ IDEA offers outstanding framework-specific coding assistance and


productivity-­boosting features for Java EE and Spring also includes very good support
for Gradle. It is the perfect choice to help you focus on learning Spring (and not how to
use an IDE). It can be downloaded from the JetBrains official site (www.jetbrains.com/
idea/). It is also light on your operating system and easy to use.
IntelliJ IDEA also integrates well with Apache Tomcat, which allows you to deploy
your projects to start and stop the server from the editor.
And now that the tools have been discussed, let’s talk about the project.

The Bookstore Project


The project containing the sources for this book is organized as a multi-module Gradle
Project. Each chapter has one or more corresponding projects that you can easily
recognize because they are prefixed with the chapter number. Table 1-1 lists these
projects and provides a short description for each.

7
Image source: https://www.jetbrains.com/idea/

6
Chapter 1 Setting up a Local Development Environment

Table 1-1. Bookstore Project Modules


Chapter Project Name Description

– bookstore-mvc-­shared Entity and utility classes used by Spring MVC projects


– bookstore-shared Entity and utility classes used by Spring Boot projects
1 chapter1-bookstore A simple Spring Boot Web MVC project with typical web
structure (static resources in the webapp directory)
1 chapter1-mvc-­ A simple Spring MVC project.
bookstore
2 chapter2-bookstore A simple Spring Boot Web MVC project with typical Boot
structure (static resources in the resources/static directory)
2 chapter2-sample A simple project with non-web samples for Chapter 2
5 chapter5-bookstore The Bookstore Spring Boot MVC project, using Thymeleaf views
6 chapter6-bookstore The Bookstore Spring Boot MVC project, using Apache Tiles
views
7 chapter7-bookstore The Bookstore Spring Boot MVC project with support for upload
files
8 chapter8-bookstore The Bookstore Spring Boot MVC project with support for various
view types
9 chapter9-1-­bookstore- The Bookstore Spring WebFlux project deployed on Apache
no-boot Tomcat (uses reactive controllers)
9 chapter9-2-­bookstore The Bookstore Spring Boot WebFlux project (uses reactive
controllers)
9 chapter9-3-­bookstore The Bookstore Spring Boot WebFlux project (uses functional
endpoints)
10 chapter10-1-­ The Bookstore Spring Boot WebFlux project supporting case-­
bookstore insensitive URIs and internationalization via a web filter (the
most elegant solution)
10 chapter10-2-­ The Bookstore Spring Boot WebFlux project supporting validation
bookstore
(continued)

7
Chapter 1 Setting up a Local Development Environment

Table 1-1. (continued)

Chapter Project Name Description

10 chapter10-3-­ The Bookstore Spring Boot WebFlux project supporting


bookstore case-insensitive URIs and internationalization via
LocaleContextResolver
11 chapter11-1-­ The Bookstore Spring Boot MVC project with WebSocket chat
bookstore
11 chapter11-2-­ The Bookstore Spring Boot WebFlux project with Tech News
bookstore emitted by a reactive stream over WebSocket
11 chapter11-3-client-­ RSocket client project
bookstore
11 chapter11-3-server-­ RSocket server project
bookstore
11 chapter11-4-server-­ The Bookstore Spring Boot WebFlux project using reactive
bookstore security
12 chapter12-­bookstore The Bookstore Spring Boot MVC project using Spring Security
12 chapter12-mvc-­ The Bookstore Spring MVC project using Spring Security
bookstore
13 chapter13-account-­ Microservice providing the Reactive Account API
service
13 chapter13-book-­ Microservice providing the Reactive Book API
service
13 chapter13-­discovery-­ Microservice discovering and registering the other microservices
service
13 chapter13-­ Microservice providing a single reactive endpoint emitting
newreleases-­service random Book instances
13 chapter13-­ Microservice with a Thymeleaf web interface interacting with the
presentation-­service other interface
13 chapter13-­technews-­ Microservice providing a single reactive endpoint emitting
service random String instances representing tech news

8
Chapter 1 Setting up a Local Development Environment

Projects with names that contain -mvc- and chapter9-1-bookstore-no-boot are


compiled and packed as a *.war can be run in Apache Tomcat. Except for chapter2-­
sample, all the other projects are built using Spring Boot and can be run by executing
their main class. The chapter2-sample project has multiple main classes that you can
run to test a specific scenario.

B
 uilding the Project
Once you’ve installed the recommended tools, the next step is getting the project sources
from GitHub.

The GitHub project page is at https://github.com/Apress/spring-­


mvc-­and-webflux.

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.

Listing 1-1. Building the Project for This Book

> gradle clean build


...
BUILD SUCCESSFUL in 3m 1s
150 actionable tasks: 148 executed, 2 up-to-date

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

To fix that, you must do the following.

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

Figure 1-6. IntelliJ IDEA Gradle and Gradle JVM setup

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

Figure 1-7. IntelliJ IDEA Project JDK setup

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

Figure 1-8. IntelliJ IDEA successful Gradle build

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

Figure 1-9. IntelliJ IDEA Launcher options

5. In the Run/Debug Configurations window, a form needs to be


populated with the location of the Apache server and the project
to deploy. First, name the configuration. Choose a name related to
your project.

6. Click the Configure button.

7. Select your Apache Tomcat server directory.

8. Click the OK button.

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.

Title: The doctor, &c., vol. 6 (of 7)

Author: Robert Southey

Editor: John Wood Warter

Release date: December 29, 2023 [eBook #72540]

Language: English

Original publication: London: Longman, Rees, Orme, Brown, Green


and Longman, 1834

Credits: Ron Swanson

*** START OF THE PROJECT GUTENBERG EBOOK THE


DOCTOR, &C., VOL. 6 (OF 7) ***
THE DOCTOR,
&c.

There is a kind of physiognomy in the titles of books no less


than in the faces of men, by which a skilful observer will as well
know what to expect from the one as the other.

BUTLER'S REMAINS.
THE DOCTOR,
&c.

VOL. VI.

LONDON:

LONGMAN, BROWN, GREEN, AND LONGMANS.


1847.

LONDON:

PRINTED BY W. NICOL, PALL-MALL.

PREFACE.

INVENIAS ETIAM DISJECTI MEMBRA POETÆ.

In the distribution of the lamented Southey's literary property, the


History of the Brazils, his much treasured MS. History of Portugal,
the Doctor, &c. and the MS. materials for its completion, fell to the
share of Edith May Warter, his eldest child, and, as he used to call
her, his right hand,—to whom he addressed the Dedication of the
Tale of Paraguay, and to whom he commenced a little Poem of
which the lines following are almost the last, if not the very last, he
ever wrote in verse.
O daughter dear, who bear'st no longer now
Thy Father's name, and for the chalky flats
Of Sussex hast exchanged thy native land
Of lakes and mountains,—neither change of place
Condition, and all circumstantial things,
Nor new relations, and access of cares
Unfelt before, have alienated thee
Nor wean'd thy heart from this beloved spot,
Thy birth place, and so long thy happy home!

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

1 Of Ridicule, 1st Series. On my acquainting Mrs. Southey with my intention of


quoting these lines, she wrote me word back: “That very passage I had noted, as
singularly applicable to him we knew so well,—whom the world, the children of this
generation,—knew so little!”

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.

JOHN WOOD WARTER.

Vicarage House,
West-Tarring, Nov. 25th.
PRELUDE OF MOTTOES.

Two thyngys owyth every clerk


To advertysyn, begynnyng a werk,
If he procedyn wyl ordeneely,
The fyrste is what, the secunde is why.
In wych two wurdys, as it semyth me
The Foure causys comprehendyd be
Wych as our philosofyrs us do teche,
In the begynnyng men owe to seche
Of every book; and aftyr there entent,
The fyrst is clepyd cause efficyent:
The secunde they clepe cause materyal,
Formal the thrydde; the fourte fynal.
The efficyent cause is the auctour,
Wych aftyr hys cunnyng doth hys labour
To a complyse the begunne matere,
Wych cause is secunde; and the more clere
That it may be, the formal cause
Settyth in dew ordre clause be clause.
And these thre thyngys, longyn to what,
Auctour, matere and forme ordinat,
The fynal cause declaryth pleynly
Of the werk begunne the cause why;
That is to seyne what was the entent
Of the auctour fynally, and what he ment.
OSBERN BOKENAM.
Look for no splendid painted outside here,
But for a work devotedly sincere;
A thing low prized in these too high-flown days:
Such solid sober works get little praise.
Yet some there be
Love true solidity.

And unto such brave noble souls I write,


In hopes to do them and the subject right.
I write it not to please the itching vein
Of idle-headed fashionists, or gain
Their fond applause;
I care for no such noise.

I write it only for the sober sort,


Who love right learning, and will labour for't;
And who will value worth in art, though old,
And not be weary of the good, though told
Tis out of fashion
By nine-tenths of the nation.

I writ it also out of great good will


Unto my countrymen; and leave my skill
Behind me for the sakes of those that may
Not yet be born; but in some after day
May make good use
Of it, without abuse.

But chiefly I do write it, for to show


A duty to the Doctor which I owe.
THOMAS MACE.

Physicians are many times forced to leave such methods of curing


as themselves know to be the fittest, and being overruled by their
patient's impatiency are fain to try the best they can in taking that
way of cure, which the cured will yield unto: in like sort, considering
how the case doth stand with this present age, full of tongue and
weak of brain, behold we yield to the stream thereof: into the causes
of goodness we will not make any curious or deep inquiry; to touch
them now and then it shall be sufficient, when they are so near at
hand that easily they may be conceived without any far removed
discourse. That way we are contented to prove, which being the
worse in itself, is notwithstanding now, by reason of common
imbecility, the fitter and likelier to be brooked.

HOOKER.

Qui lit beaucoup et jamais ne medite,


Semble à celuy qui mange avidement,
Et de tous mets surcharge tellement
Son estomach que rien ne luy profit.
QUATRAINE DE PIBRAC.

thus englished by Sylvester,

Who readeth much and never meditates,


Is like a greedy eater of much food,
Who so surcloys his stomach with his cates
That commonly they do him little good.

Je sçay qu'en ce discours l'on me pourra reprendre, que j'ay mis


beaucoup de particularitez qui sont fort superfluës. Je le crois: mais,
je sçay, que si elles desplaisent à aucuns, elles plairont aux autres:
me semblant, que ce n'est pas assez, quand on louë des personnes,
dire qu'elles sont belles, sages, vertueuses, valeureuses, vaillantes,
magnanimes, libérales, splendides et très-parfaites. Ce sont
loüanges et descriptions genérales, et lieux-communs empruntez de
tout le monde. Il en faut specifier bien le tout, et descrire
particuliérement les perfections, afin que mieux on les touche au
doigt: et telle est mon opinion.
BRANTOME.

Non sai se l'arte, o il caso abbia fornita


Cosi bell' opra, o siano entrambi a parte;
Perocchè l'arte è tal che il caso imita,
E'l caso è tal che rassomiglia all' arte:
E questo a quella, e quella a questo unita,
Quanto può, quanto sa, mesce e comparte.
Un la materia al bel lavor dispose,
L'altra meglio adornolla, e poi s'ascose.
METASTASIO.

Tous ceux qui ont quelquesfois pesé le grand travail et le labeur de


l'imagination, l'ont jugé pour le plus grand qui se puisse trouver, et
ont eu raison; d'autant que celuy lequel veut et desire en contenter
plusieurs, doit aussi chercher des moyens differens, afin que ce qui
est ennuyeux à l'un, l'autre le trouve doux et agreable; car de le
donner à tous, il est impossible; veu, qu' entre trois personnes
seulement que l'on aura conviées, il se trouvera une grande
diference de gouts, ainsi que l'a dit Horace, luy, dis-je qui l'avoit si
bien experimenté: par ainsi il n'est pas possible qu'en une si longue
histoire que celle dont je vay traictant, que je ne donne de la peine
par la diversité des chapitres. Toutetfois si le jugement s'en faict par
des personnes privees et libres de toute passion, ils diront que c'est
le vray moyen d'entretenir les esprits curieux.

L'HISTOIRE DU CHEVALIER DU SOLEIL.

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.

In some passages you will observe me very satirical. Writing on such


subjects I could not be otherwise. I can write nothing without aiming,
at least, at usefulness. It were beneath my years to do it, and still
more dishonourable to my religion. I know that a reformation of such
abuses as I have censured is not to be expected from the efforts of
an author; but to contemplate the world, its follies, its vices, its
indifferences to duty, and its strenuous attachment to what is evil,
and not to reprehend, were to approve it. From this charge, at least, I
shall be clear; for I have neither tacitly, nor expressly flattered either
its characters or its customs.

COWPER.

Nemo eo sapientius desipuisse, nemo stultius sapuisse videtur.

Said of Cardan by I know not who.

Il y en a qui pensent que les lecteurs reçoivent peu d'instruction,


quand on leur représente des choses qui n'ont pas esté achevées,
qu'eux appellent œuvres imparfaites; mais je ne suis pas de leur
advis; car quand quelque fait est descrit à la verité, et avec ses
circonstances, encor qu'il ne soit parvenu qu' à mychemin, si peut-on
tousjours en tirer du fruict.

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.

Thus have I, as well as I could, gathered a posey of observations as


they grew,—and if some rue and wormwood be found amongst the
sweeter herbs, their wholesomeness will make amends for their
bitterness.

ADAM LITTLETON.

This worthy work in which of good examples are so many,


This orchard of Alcinous, in which there wants not any
Herb, tree, or fruit that may mans use for health or pleasure serve;
This plenteous horn of Acheloy, which justly doth deserve
To bear the name of Treasury of Knowledge, I present
To your good worships once again,—desiring you therefore
To let your noble courtesy and favour countervail
My faults, where art or eloquence on my behalf doth fail,
For sure the mark whereat I shoot is neither wreaths of bay,
Nor name of author, no, nor meed; but chiefly that it may
Be liked well of you and all the wise and learned sort;
And next, that every wight that shall have pleasure for to sport
Him in this garden, may as well bear wholesome fruit away
As only on the pleasant flowers his retchless senses stay.
GOLDING.
Doubtless many thoughts have presented, and are still presenting
themselves to my mind, which once I had no idea of. But these, in I
believe every instance, are as much the growth of former rooted
principles, as multiplied branches grow from one and the same main
stem. Of such an inward vegetation I am always conscious; and I
equally seem to myself to perceive the novelty of the fresh shoot,
and its connexion with what had been produced before.

ALEXANDER KNOX.

The extensive argument and miscellaneous nature of the work led


him to declare his sentiments on a multitude of questions, on which
he thought differently from other writers, and of course, to censure or
confute their opinions. Whole bodies of men, as well as individuals of
the highest reputation, were attacked by him, and his manner was to
speak his sense of all with freedom and force. So that most writers,
and even readers, had some ground of complaint against him. Not
only the free-thinkers and unbelievers, against whom the tenour of
his book was directed, but the heterodox of every denomination were
treated without much ceremony, and of the orthodox themselves,
some tenet or other, which till then they had held sacred, was
discussed and reprobated by him. Straggling heresies, or embodied
systems, made no difference with him; as they came in his way, no
quarter was given to either, “his end and manner of writing,” as Dr.
Middleton truly observed, “being to pursue truth wherever he found
it.”

HURD'S LIFE OF WARBURTON.

Thou art like my rappee, here, a most ridiculous superfluity; but a


pinch of thee now and then is a more delicious treat.
CLANDESTINE MARRIAGE.

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.

It may appear to some ridiculous


Thus to talk knave and madman, and sometimes
Come in with a dried sentence, stuft with sage.
WEBSTER.

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.

DESCARTES' NOTION CONCERNING THE PROLONGATION OF LIFE. A SICILIAN


PROPOSAL FOR BREEDING UP CHILDREN TO BE IMMORTAL. ASGILL'S
ARGUMENT AGAINST THE NECESSITY OF DYING.

O harmless Death! whom still the valiant brave,


The wise expect, the sorrowful invite;
And all the good embrace, who know the Grave
A short dark passage to eternal light.
SIR WILLIAM DAVENANT.

CLXXIII.

MORE CONCERNING ASGILL. HIS DEFENCE IN THE HOUSE OF COMMONS,


HIS EXPULSION, FARTHER SPECULATIONS AND DEATH.

Let not that ugly Skeleton appear!


Sure Destiny mistakes; this Death's not mine!
DRYDEN.

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.

My mouth's no dictionary; it only serves as the needful interpreter of my heart.

QUARLES.

CHAPTER CLXXV.

THE DOCTOR FOLLOWS UP HIS MEDITATIONS ON THE LETTER D. AND


EXPECTS THAT THE READER WILL BE CONVINCED THAT IT IS A DYNAMIC
LETTER, AND THAT THE HEBREWS DID NOT WITHOUT REASON CALL IT
DALETH—THE DOOR—AS THOUGH IT WERE THE DOOR OF SPEECH.—THE
MYSTIC TRIANGLE.

More authority dear boy, name more; and sweet my child let them be men of good
repute and carriage.—

LOVE'S LABOUR LOST.

CHAPTER CLXXVI.

THE DOCTOR DISCOVERS THE ANTIQUITY OF THE NAME OF DOVE FROM


PERUSING JACOB BRYANT'S ANALYSIS OF ANCIENT MYTHOLOGY.—
CHRISTOPHER AND FERDINAND COLUMBUS.—SOMETHING ABOUT PIGEON-
PIE, AND THE REASON WHY THE DOCTOR WAS INCLINED TO THINK
FAVOURABLY OF THE SAMARITANS.

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.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like