Spring Boot - Accessories
Spring Boot - Accessories
Version: 3.0 - Date: 04.2021
About the Book
This is second Book in the series
Intention of this Book is to quickly get you started with non-core Spring Boot functionalities like: Validation, Testing, Logging, Filters, Interceptors, etc.
The core of this Book are standalone tutorials that explain different functionalities of Spring Boot.
Each tutorial contains minimum amount of code needed to explain specific functionality.
And also minimum amount of encompassing text that explains related theory and different parts of the code.
This approach allows students to grasp presented concepts in a very fast and efficient manner.
Full code, which can also be downloaded from GitHub, prevents any time being wasted trying to make the code work.
Simple examples allow for full understanding of the functionality without any unnecessary distractions.
Where needed tutorials are preceded by chapters focusing on theoretical background.
This way reader can fully understand functionalities explained in the subsequent chapters.
But such chapters are in minority and of secondary importance because the main focus is on practical applications.
Book contains demo Application Currencies that shows how to combine functionalities covered in the tutorials.
Bundles that include this book
Table of Contents
- 1. Different Functionalities
- 1.1 Validation
- 1.1.1 Validate - Request Parameters
- 1.1.2 Validate - DTO - From Request Parameters
- 1.1.3 Validate - DTO - From JSON
- 1.1.4 Validate - Custom Annotation
- 1.1.5 Catch Exception - Using @ExceptionHandler
- 1.1.6 Catch Exception - Using @ControllerAdvice
- 1.1.7 Throw Exception
- 1.2 WebClient
- 1.2.1 Server
- 1.2.2 Client - Mono
- 1.2.3 Client - Flux
- 1.3 Tasks
- 1.3.1 Startup
- 1.3.2 Scheduled
- 1.4 Custom Banner
- 2. Filters & Interceptors
- 2.1 Filters
- 2.1.1 Create Filter - Using Implements Filter
- 2.1.2 Create Filter - Using Extends OncePerRequestFilter
- 2.1.3 Create Filter Chain
- 2.1.4 Block Requests
- 2.1.5 HTTP Request Parameters - Get
- 2.1.6 HTTP Request Parameters - Add
- 2.1.7 HTTP Request Parameters - Edit
- 2.1.8 Apply Filter only for specific URL
- 2.2 Interceptors
- 2.2.1 Create Interceptor - Implements HandlerInterceptor
- 2.2.2 Create Interceptor Chain
- 2.2.3 HTTP Request/Response - Get Parameters
- 3. Logging
- 3.1 Slf4j
- 3.1.1 Using LoggerFactory
- 3.1.2 Using @Slf4j
- 3.1.3 Logback
- 3.1.4 Logback - Configure - XML
- 3.1.5 Logback - Configure - XML - DB
- 3.1.6 Logback - Configure - XML - DB - Custom
- 3.1.7 Logback - Configure - Properties
- 3.1.8 Log4j
- 3.1.9 Log4j - Configure - XML
- 3.1.10 Log4j - Configure - Properties
- 3.2 AOP Annotations
- 3.2.1 Log Start End
- 3.2.2 Log Execution Time
- 4. Testing
- 4.1 JUnit 5
- 4.1.1 Create Test Class - Manually
- 4.1.2 Create Test Class - Automatically
- 4.1.3 Run Tests
- 4.1.4 Example
- 4.1.5 @SpringBootTest
- 4.1.6 @Test
- 4.1.7 @Disable
- 4.1.8 @BeforeAll, @AfterAll, @BeforeEach, @AfterEach
- 4.1.9 assert...()
- 4.1.10 assertThrows()
- 4.2 Mockito
- 4.2.1 Mock - Object - @Mock
- 4.2.2 Mock - Object - @MockBean
- 4.2.3 Mock - Object - @Spy
- 4.2.4 Mock - Object - @Spybean
- 4.2.5 Mock - Method - when()
- 4.2.6 Mock - Method - given()
- 4.2.7 Mock - Method - doReturn()
- 4.2.8 @InjectMocks
- 4.2.9 verify()
- 4.2.10 verify() - ArgumentMatchers
- 4.2.11 verify() - ArgumentCaptor
- 4.3 MockMVC
- 4.3.1 @WebMvcTest
- 4.3.2 Test - Request - URL Mapping
- 4.3.3 Test - Request - Parameters
- 4.3.4 Test - Request - Path Variables
- 4.3.5 Test - Request - Body - JSON
- 4.3.6 Test - Response - Status
- 4.3.7 Test - Response - Body - Text
- 4.3.8 Test - Response - Body - JSON
- 5. Demo Applications
- 5.1 Currencies
- 5.1.1 Step 1 - Load Data
- 5.1.2 Step 2 - Controller
- 5.1.3 Step 3 - Validation
- 5.1.4 Step 4 - Security
- 5.1.5 Step 5 - Logging with Annotation into File
- 5.1.6 Step 6 - Logging with Filter into DB
- 5.1.7 Step 7 - Download Excel with DB Log
- 5.1.8 Step 8 - Unit Testing
- 6. Appendix
- 6.1 IntelliJ
- 6.1.1 Install
- 6.1.2 Create Project
- 6.1.3 Run Application
- 6.2 JUnit
- 6.2.1 Test Exception
- 6.3 Lombok
- 6.3.1 Lombok API - Use
- 6.3.2 Lombok Plugin - Install for IntelliJ
- 6.3.3 Lombok Plugin - Lombok
- 6.3.4 Lombok Plugin - Delombok
- 6.4 Mockito
- 6.4.1 @Mock - Into Property
- 6.4.2 @Mock - Into Setter
- 6.4.3 @Mock - Into Constructor
- 6.5 Swagger
- 6.5.1 GET
- 6.5.2 POST
- 6.5.3 Error - Unable to infer base URL
- 7. Summary
- 7.1 Different Functionalities
- 7.1.1 Validation
- 7.1.2 Tasks
- 7.1.3 WebClient
- 7.1.4 Custom Banner
- 7.2 Filters & Interceptors
- 7.2.1 Filters
- 7.2.2 Interceptors
- 7.3 Logging
- 7.3.1 Slf4J
- 7.3.2 Logback
- 7.3.3 Log4j2
- 7.4 Testing
- 7.4.1 JUnit 5
- 7.4.2 Mockito
- 7.4.3 MockMVC
The Leanpub 60-day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
80% Royalties. Earn $16 on a $20 book.
We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $12 million USDwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them