Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +10 -0
- 13 - Object-oriented programming/015 Dependency Inversion Principle.mp4 +3 -0
- 16 - === EXAM OOP & Object Oriented e-Commerce console applications ===/001 Exam and homework for OOP topic.mp4 +3 -0
- 17 - GIT/001 Version Control Systems & Git - Overview.mp4 +3 -0
- 17 - GIT/002 How to Install Git and Basic Git Configuration.mp4 +3 -0
- 17 - GIT/004 Git repo init, First commit and main bracnh.mp4 +3 -0
- 17 - GIT/005 Git ignoring & Git log.mp4 +3 -0
- 17 - GIT/006 Git undoing things & Vi text editor.mp4 +3 -0
- 17 - GIT/007 Git remote repositories.mp4 +3 -0
- 17 - GIT/008 SSH Connection.mp4 +3 -0
- 17 - GIT/010 Pull Requests & Merge Requests.mp4 +3 -0
- 84 - Spring Security/external-links.txt +12 -0
- 85 - ===== EXAM Spring Security - Online Shop =====/001 EXAM Spring Security - Online Shop_en.srt +1240 -0
- 85 - ===== EXAM Spring Security - Online Shop =====/001 Exam-task-description-with-the-reference-to-the-solution.url +2 -0
- 85 - ===== EXAM Spring Security - Online Shop =====/external-links.txt +3 -0
- 86 - Spring Data/001 Spring Data & Spring Data JPA Overview_en.srt +664 -0
- 86 - Spring Data/002 Source-code-of-examples-commit-with-changes-.url +2 -0
- 86 - Spring Data/002 Spring Data JPA Practice_en.srt +996 -0
- 86 - Spring Data/external-links.txt +3 -0
- 87 - ===== EXAM Spring Data JPA - Online Shop =====/001 EXAM Spring Data JPA - Online Shop.html +69 -0
- 88 - Spring JDBC/001 Spring JDBC Overview_en.srt +624 -0
- 88 - Spring JDBC/002 Source-code-of-examples-commit-with-changes-.url +2 -0
- 88 - Spring JDBC/002 Spring JDBC Practice_en.srt +1396 -0
- 88 - Spring JDBC/external-links.txt +3 -0
- 89 - ===== EXAM Spring JDBC - Online Shop =====/001 EXAM Spring JDBC - Online Shop.html +69 -0
- 90 - Spring AOP/001 Aspect Oriented Programming_en.srt +860 -0
- 90 - Spring AOP/002 Source-code-of-examples-commit-with-changes-.url +2 -0
- 90 - Spring AOP/002 Spring AOP with AspectJ Practice_en.srt +1076 -0
- 90 - Spring AOP/external-links.txt +3 -0
- 91 - REST Architecture/001 REST Architecture Overview and Key Principles_en.srt +1012 -0
- 91 - REST Architecture/002 Naming Convention for RESTful Services_en.srt +820 -0
- 91 - REST Architecture/003 RESTful Service Implementation with Spring MVC_en.srt +1092 -0
- 91 - REST Architecture/003 Source-code-of-examples-commit-with-changes-.url +2 -0
- 91 - REST Architecture/004 Review of tools for API testing & Postman Installation_en.srt +664 -0
- 91 - REST Architecture/005 API Testing with Postman_en.srt +1140 -0
- 91 - REST Architecture/005 Commit-with-changes.url +2 -0
- 91 - REST Architecture/005 Postman-collections.url +2 -0
- 91 - REST Architecture/external-links.txt +9 -0
- 92 - Spring Boot/001 Spring Boot Introduction_en.srt +1084 -0
- 92 - Spring Boot/002 Source-code-of-the-first-Spring-Boot-project-from-the-lesson-commit-with-changes-.url +2 -0
- 92 - Spring Boot/002 Spring-Initializr-Tool.url +2 -0
- 92 - Spring Boot/002 The First Spring Boot Project_en.srt +876 -0
- 92 - Spring Boot/003 Source-code-of-examples-commit-with-changes-.url +2 -0
- 92 - Spring Boot/003 Spring Boot Starters_en.srt +1612 -0
- 92 - Spring Boot/003 Spring-Boot-Starters-on-Github.url +2 -0
- 92 - Spring Boot/004 Common-Spring-Boot-Application-Properties.url +2 -0
- 92 - Spring Boot/004 Source-code-of-examples-commit-with-changes-.url +2 -0
- 92 - Spring Boot/004 Spring Boot Configurations & Application Properties_en.srt +1448 -0
- 92 - Spring Boot/005 Source-code-of-examples-commit-with-changes-.url +2 -0
- 92 - Spring Boot/005 Spring Boot Actuator - Monitoring Tools_en.srt +1184 -0
.gitattributes
CHANGED
|
@@ -129,3 +129,13 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 129 |
13[[:space:]]-[[:space:]]Object-oriented[[:space:]]programming/009[[:space:]]Object,[[:space:]]JNI[[:space:]]and[[:space:]]Object[[:space:]]class[[:space:]]overview.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 130 |
13[[:space:]]-[[:space:]]Object-oriented[[:space:]]programming/013[[:space:]]Liskov[[:space:]]Substitution[[:space:]]Principle.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 131 |
13[[:space:]]-[[:space:]]Object-oriented[[:space:]]programming/014[[:space:]]Interface[[:space:]]Segregation[[:space:]]Principle.mp4 filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
13[[:space:]]-[[:space:]]Object-oriented[[:space:]]programming/009[[:space:]]Object,[[:space:]]JNI[[:space:]]and[[:space:]]Object[[:space:]]class[[:space:]]overview.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 130 |
13[[:space:]]-[[:space:]]Object-oriented[[:space:]]programming/013[[:space:]]Liskov[[:space:]]Substitution[[:space:]]Principle.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 131 |
13[[:space:]]-[[:space:]]Object-oriented[[:space:]]programming/014[[:space:]]Interface[[:space:]]Segregation[[:space:]]Principle.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 132 |
+
13[[:space:]]-[[:space:]]Object-oriented[[:space:]]programming/015[[:space:]]Dependency[[:space:]]Inversion[[:space:]]Principle.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 133 |
+
17[[:space:]]-[[:space:]]GIT/001[[:space:]]Version[[:space:]]Control[[:space:]]Systems[[:space:]]&[[:space:]]Git[[:space:]]-[[:space:]]Overview.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 134 |
+
16[[:space:]]-[[:space:]]===[[:space:]]EXAM[[:space:]]OOP[[:space:]]&[[:space:]]Object[[:space:]]Oriented[[:space:]]e-Commerce[[:space:]]console[[:space:]]applications[[:space:]]===/001[[:space:]]Exam[[:space:]]and[[:space:]]homework[[:space:]]for[[:space:]]OOP[[:space:]]topic.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 135 |
+
17[[:space:]]-[[:space:]]GIT/004[[:space:]]Git[[:space:]]repo[[:space:]]init,[[:space:]]First[[:space:]]commit[[:space:]]and[[:space:]]main[[:space:]]bracnh.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 136 |
+
17[[:space:]]-[[:space:]]GIT/005[[:space:]]Git[[:space:]]ignoring[[:space:]]&[[:space:]]Git[[:space:]]log.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 137 |
+
17[[:space:]]-[[:space:]]GIT/002[[:space:]]How[[:space:]]to[[:space:]]Install[[:space:]]Git[[:space:]]and[[:space:]]Basic[[:space:]]Git[[:space:]]Configuration.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 138 |
+
17[[:space:]]-[[:space:]]GIT/006[[:space:]]Git[[:space:]]undoing[[:space:]]things[[:space:]]&[[:space:]]Vi[[:space:]]text[[:space:]]editor.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 139 |
+
17[[:space:]]-[[:space:]]GIT/007[[:space:]]Git[[:space:]]remote[[:space:]]repositories.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 140 |
+
17[[:space:]]-[[:space:]]GIT/008[[:space:]]SSH[[:space:]]Connection.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 141 |
+
17[[:space:]]-[[:space:]]GIT/010[[:space:]]Pull[[:space:]]Requests[[:space:]]&[[:space:]]Merge[[:space:]]Requests.mp4 filter=lfs diff=lfs merge=lfs -text
|
13 - Object-oriented programming/015 Dependency Inversion Principle.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4839fd3d0b1411e30add8cf0f50a648927c520582c774aa9487fa2cced8add20
|
| 3 |
+
size 97920838
|
16 - === EXAM OOP & Object Oriented e-Commerce console applications ===/001 Exam and homework for OOP topic.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:10683a9dfc1d5f7fb211f447a48dab53b3f98038444979089255d4ee0a180ce6
|
| 3 |
+
size 153802800
|
17 - GIT/001 Version Control Systems & Git - Overview.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3fee90b68e09558b6d846df640bad96f49f8d3f2b2baadaa9d61f3210b43d5bb
|
| 3 |
+
size 57399220
|
17 - GIT/002 How to Install Git and Basic Git Configuration.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c8ada8b8b5e0e12969640b928bd897baa5209608777aecf750847b3ccf974ee4
|
| 3 |
+
size 158468542
|
17 - GIT/004 Git repo init, First commit and main bracnh.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c13262001a8309cdd0954965676b57ea401c0758db2a02b3d2eaae49c6e391d1
|
| 3 |
+
size 38282816
|
17 - GIT/005 Git ignoring & Git log.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a1be93c5595bd47cb49c7079acfb695a6c90941d35f21b52f5adb6a1c148a1e0
|
| 3 |
+
size 133419159
|
17 - GIT/006 Git undoing things & Vi text editor.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a7de076f8653cd0d370273844dab3154041cb461d1521c2c9f9354731f57daf6
|
| 3 |
+
size 147540639
|
17 - GIT/007 Git remote repositories.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d1eba26a36847641bc5071a7daa9bca13ed5ebae58553a9b23607abd89ffa61a
|
| 3 |
+
size 105054427
|
17 - GIT/008 SSH Connection.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b09ac33aaf19880dba5d977f30da4c0eb7b0ac7be1670dab5c17433b34bae49e
|
| 3 |
+
size 108866715
|
17 - GIT/010 Pull Requests & Merge Requests.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9f270121a98d4f62d1be9c2a62ecd828eac4ed9ce45f4377b8bf9e40e0a7aae4
|
| 3 |
+
size 140071769
|
84 - Spring Security/external-links.txt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
002 Source-code-of-examples-commit-with-changes-
|
| 3 |
+
https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/fa1f32b831ae40f681525076f3c8bd8928807f48
|
| 4 |
+
|
| 5 |
+
003 Source-code-of-examples-commit-with-changes-
|
| 6 |
+
https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/54608d3a38dc7bf0ec826a5210082f931bcf4ce4
|
| 7 |
+
|
| 8 |
+
004 Source-code-of-examples-commit-with-changes-
|
| 9 |
+
https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/9c0322078c8402104870492f91fc9713fc5f615a
|
| 10 |
+
|
| 11 |
+
005 Source-code-of-examples-commit-with-changes-
|
| 12 |
+
https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/8dddc2feb47bce4664713763e10e3fd9fda9648b
|
85 - ===== EXAM Spring Security - Online Shop =====/001 EXAM Spring Security - Online Shop_en.srt
ADDED
|
@@ -0,0 +1,1240 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:06,000 --> 00:00:06,000
|
| 3 |
+
Hello, team.
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:06,000 --> 00:00:13,000
|
| 7 |
+
We have learned a lot about spring security and now it is time for you to practice your skills and realize
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:13,000 --> 00:00:16,000
|
| 11 |
+
how much you already learned in the course.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:16,000 --> 00:00:22,000
|
| 15 |
+
As you know, with all my students during the whole course Java from zero to first job, we develop
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:22,000 --> 00:00:25,000
|
| 19 |
+
our online shop from scratch.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:25,000 --> 00:00:32,000
|
| 23 |
+
I truly believe that real business case will help you to understand how to apply gained knowledge on
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:32,000 --> 00:00:33,000
|
| 27 |
+
practice.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:33,000 --> 00:00:39,000
|
| 31 |
+
And in this exam task we are going to improve our existing web application by adding spring security
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:39,000 --> 00:00:40,000
|
| 35 |
+
features to it.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:40,000 --> 00:00:44,000
|
| 39 |
+
Let's review this document with the exam task description.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:44,000 --> 00:00:48,000
|
| 43 |
+
We'll make sure that you understand the task.
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:48,000 --> 00:00:51,000
|
| 47 |
+
After that, you will try to implement the task.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:51,000 --> 00:00:56,000
|
| 51 |
+
And at the end of the video lesson, I am going to share with you my solution, and we are going to
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:56,000 --> 00:00:57,000
|
| 55 |
+
discuss it.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:57,000 --> 00:01:01,000
|
| 59 |
+
So let's start with the review of the exam task.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:01:02,000 --> 00:01:07,000
|
| 63 |
+
The first thing that you need to do is to clone repository with our online shop.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:01:07,000 --> 00:01:13,000
|
| 67 |
+
In my course, Java from zero to first job will develop online shop from scratch and usually during
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:01:13,000 --> 00:01:19,000
|
| 71 |
+
each following exam task, we continue from the point where we stopped last time.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:01:20,000 --> 00:01:23,000
|
| 75 |
+
So here is the link to the repository.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:01:23,000 --> 00:01:24,000
|
| 79 |
+
It is solution.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:01:24,000 --> 00:01:30,000
|
| 83 |
+
After completion of the previous exam task, when we finished integration of the Spring core and spring
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:01:30,000 --> 00:01:32,000
|
| 87 |
+
MVC into our solution.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:01:33,000 --> 00:01:38,000
|
| 91 |
+
And now it is time to add spring security features into our application.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:01:38,000 --> 00:01:46,000
|
| 95 |
+
So once you clone the repository, try to run the application and make sure that you don't have errors
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:01:46,000 --> 00:01:47,000
|
| 99 |
+
during the startup.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:01:47,000 --> 00:01:51,000
|
| 103 |
+
It would also require you to configure database.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:01:51,000 --> 00:01:57,000
|
| 107 |
+
Basically, you can refer to the README inside the repository and follow simple steps.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:01:57,000 --> 00:02:04,000
|
| 111 |
+
The main thing is to configure the database server, create schema, configure the schema inside the
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:02:04,000 --> 00:02:09,000
|
| 115 |
+
application, and after that you can let hibernate, create all necessary tables.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:02:09,000 --> 00:02:16,000
|
| 119 |
+
But after that, in order to bring life to the application, you need to insert some data manually.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:02:16,000 --> 00:02:21,000
|
| 123 |
+
For example, information about products, about orders and things like that.
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:02:22,000 --> 00:02:23,000
|
| 127 |
+
Everything is prepared for you.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:02:23,000 --> 00:02:27,000
|
| 131 |
+
You just need to follow the steps described in the README file.
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:02:27,000 --> 00:02:31,000
|
| 135 |
+
You can find the folder with data to insert into the database.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:02:31,000 --> 00:02:38,000
|
| 139 |
+
Once you configure it application and manage to start it successfully, just navigate between pages,
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:02:38,000 --> 00:02:42,000
|
| 143 |
+
Try to understand how it works just in case.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:02:42,000 --> 00:02:48,000
|
| 147 |
+
All business requirements that we implemented in the online shop are located in this file.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:02:48,000 --> 00:02:54,000
|
| 151 |
+
Feel free to look through it to understand the functionality of the application better.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:02:54,000 --> 00:03:00,000
|
| 155 |
+
It is recommended to make this overview of the functionality in order you can make sure that nothing
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:03:00,000 --> 00:03:03,000
|
| 159 |
+
is broken Once you completed the home task.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:03:03,000 --> 00:03:08,000
|
| 163 |
+
And now you can start with the integration of the spring security with our application.
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:03:08,000 --> 00:03:15,000
|
| 167 |
+
The first thing that you need to do is to configure authentication and security filter in the application.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:03:15,000 --> 00:03:22,000
|
| 171 |
+
We already have login page, So like we already learned in one of the lessons we need to configure spring
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:03:22,000 --> 00:03:25,000
|
| 175 |
+
security with the custom login page.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:03:25,000 --> 00:03:26,000
|
| 179 |
+
Be attentive.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:03:26,000 --> 00:03:32,000
|
| 183 |
+
During the integration we learned everything you need to know to complete this part of the task.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:03:32,000 --> 00:03:37,000
|
| 187 |
+
So in case you need to refresh your knowledge, feel free to get back to the lessons that we already
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:03:37,000 --> 00:03:38,000
|
| 191 |
+
watched.
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:03:38,000 --> 00:03:40,000
|
| 195 |
+
Secure Protected Resources.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:03:40,000 --> 00:03:47,000
|
| 199 |
+
You need to secure order management resources to be accessible only to users with the admin and manager
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:03:47,000 --> 00:03:53,000
|
| 203 |
+
roles and make admin resource available only for users with admin role.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:03:53,000 --> 00:03:59,000
|
| 207 |
+
Just remember that we don't have to store passwords in the database in the raw format.
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:04:00,000 --> 00:04:05,000
|
| 211 |
+
Always encode passwords before putting them into the database.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:04:05,000 --> 00:04:12,000
|
| 215 |
+
Our current solution uses custom encoder, but within the task I want to use password encoder been to
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:04:12,000 --> 00:04:19,000
|
| 219 |
+
encode passwords and too much raw password and encoded version of the password when needed.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:04:20,000 --> 00:04:27,000
|
| 223 |
+
I want you to implement application in the way where we can assign user to multiple roles.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:04:27,000 --> 00:04:33,000
|
| 227 |
+
In simple words, you need to be able to store array of roles inside the user.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:04:33,000 --> 00:04:36,000
|
| 231 |
+
Your user can have manager and admin role simultaneously.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:04:36,000 --> 00:04:37,000
|
| 235 |
+
For example.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:04:38,000 --> 00:04:41,000
|
| 239 |
+
Each role in turn can have multiple privileges.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:04:41,000 --> 00:04:48,000
|
| 243 |
+
For example, admin role can have read, write and delete privilege and manager user can have only read
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:04:48,000 --> 00:04:49,000
|
| 247 |
+
and write privilege.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:04:50,000 --> 00:04:57,000
|
| 251 |
+
This is just an example, but I believe that you understood that role may contain multiple privileges
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:04:57,000 --> 00:05:00,000
|
| 255 |
+
and each privilege can have multiple roles.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:05:01,000 --> 00:05:02,000
|
| 259 |
+
There will be many to many relation.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:05:02,000 --> 00:05:03,000
|
| 263 |
+
ActionScript.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:05:04,000 --> 00:05:08,000
|
| 267 |
+
Also want to implement Remember me functionality.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:05:08,000 --> 00:05:15,000
|
| 271 |
+
Be attentive because this would also require you to put authenticated user into the session when needed
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:05:15,000 --> 00:05:24,000
|
| 275 |
+
because such element as header in our online shop relies on the user that is stored in the session taking
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:05:24,000 --> 00:05:25,000
|
| 279 |
+
into account user.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:05:25,000 --> 00:05:31,000
|
| 283 |
+
In the session we show username and we change button in the header.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:05:31,000 --> 00:05:39,000
|
| 287 |
+
Namely when the user is logged in, we don't need to show button sign in and sign up, we just need
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:05:39,000 --> 00:05:41,000
|
| 291 |
+
to show sign out button.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:05:41,000 --> 00:05:44,000
|
| 295 |
+
Think about how you will implement this.
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:05:44,000 --> 00:05:49,000
|
| 299 |
+
For users who just registered, we need to set customer role by default.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:05:49,000 --> 00:05:56,000
|
| 303 |
+
Make sure that the registration login logout remember me and access restrictions functionality works
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:05:56,000 --> 00:05:57,000
|
| 307 |
+
as expected.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:05:58,000 --> 00:06:03,000
|
| 311 |
+
I believe you can easily complete this task because there is nothing what we didn't discuss during the
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:06:04,000 --> 00:06:05,000
|
| 315 |
+
learning course.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:06:05,000 --> 00:06:11,000
|
| 319 |
+
So now I recommend you to put on pause the video and proceed with the implementation.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:06:11,000 --> 00:06:19,000
|
| 323 |
+
And once you are done we are going to review my solution and changes that I did to compare yours and
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:06:19,000 --> 00:06:20,000
|
| 327 |
+
my solution.
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:06:20,000 --> 00:06:27,000
|
| 331 |
+
As you see all conditions and development environment is super close to the reality when you will get
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:06:27,000 --> 00:06:31,000
|
| 335 |
+
new task assigned on you in real life.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:06:31,000 --> 00:06:37,000
|
| 339 |
+
Because in real life nobody would specify what files you need to fix or change.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:06:38,000 --> 00:06:45,000
|
| 343 |
+
You need to find the files that are needed to be changed in order to meet the requirements of the task.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:06:45,000 --> 00:06:50,000
|
| 347 |
+
And this is also part of your education in this course to be ready for real life.
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:06:51,000 --> 00:06:57,000
|
| 351 |
+
So I bet that you completed the home task and now you're ready to review the solution together with
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:06:57,000 --> 00:06:58,000
|
| 355 |
+
me.
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:06:58,000 --> 00:07:04,000
|
| 359 |
+
First of all, I want to highlight that completely working solution is located in the separate repository.
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:07:04,000 --> 00:07:07,000
|
| 363 |
+
You can find link here.
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:07:07,000 --> 00:07:13,000
|
| 367 |
+
Feel free to clone it on your local computer to run it and explore it better.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:07:14,000 --> 00:07:21,000
|
| 371 |
+
In case you want to explore only changes, here is a commit with all changes that I did to implement
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:07:21,000 --> 00:07:22,000
|
| 375 |
+
this coding exercise.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:07:23,000 --> 00:07:28,000
|
| 379 |
+
Let's review it together and I will give you my comments as we will go over.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:07:28,000 --> 00:07:31,000
|
| 383 |
+
I opened the commit with changes.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:07:31,000 --> 00:07:33,000
|
| 387 |
+
Let's review each file.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:07:33,000 --> 00:07:41,000
|
| 391 |
+
I introduced Ralph Facade in my business layer, just to remind you that when we learned layered architecture,
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:07:41,000 --> 00:07:45,000
|
| 395 |
+
we made a decision to follow layered architecture pattern.
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:07:45,000 --> 00:07:51,000
|
| 399 |
+
And in the solution we have strict separation between business layer and persistence layer.
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:07:51,000 --> 00:07:55,000
|
| 403 |
+
So you can see that row facade is in our core module.
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:07:55,000 --> 00:07:57,000
|
| 407 |
+
In the business layer.
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:07:57,000 --> 00:08:00,000
|
| 411 |
+
We need to be able to extract role by name.
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:08:01,000 --> 00:08:05,000
|
| 415 |
+
The implementation of the role facade is default role facade.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:08:06,000 --> 00:08:13,000
|
| 419 |
+
Inject role DAO into this class and role to roll converter.
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:08:13,000 --> 00:08:14,000
|
| 423 |
+
On the business layer.
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:08:14,000 --> 00:08:18,000
|
| 427 |
+
We operate with the business models on the persistence layer.
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:08:18,000 --> 00:08:21,000
|
| 431 |
+
We work with the data transfer objects.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:08:21,000 --> 00:08:27,000
|
| 435 |
+
That's why we need converters to convert from object to the business model.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:08:27,000 --> 00:08:34,000
|
| 439 |
+
Moreover, this architecture in the future will allow you to add any business behavior to your business
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:08:34,000 --> 00:08:41,000
|
| 443 |
+
model because methods with business logic, it is not something what you have to store in the objects
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:08:41,000 --> 00:08:42,000
|
| 447 |
+
on the persistence layer.
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:08:42,000 --> 00:08:48,000
|
| 451 |
+
That's why from one side this architecture gives you better scalability.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:08:48,000 --> 00:08:55,000
|
| 455 |
+
But at the same time, this architecture adds code complexity because of the additional classes.
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:08:55,000 --> 00:09:00,000
|
| 459 |
+
This challenge is addressed in different frameworks in different way.
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:09:00,000 --> 00:09:07,000
|
| 463 |
+
For example, there are already invented code generation tools that generates code automatically, taking
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:09:07,000 --> 00:09:10,000
|
| 467 |
+
into account the structure of the data.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:09:10,000 --> 00:09:18,000
|
| 471 |
+
Object and converter is easy to define, and you can also create a code that will generate source code
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:09:18,000 --> 00:09:23,000
|
| 475 |
+
of dtos and converters based on the XML configuration by yourself.
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:09:23,000 --> 00:09:31,000
|
| 479 |
+
In other words, you can define your data types in the XML file, for example, and generate all required
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:09:31,000 --> 00:09:32,000
|
| 483 |
+
details automatically.
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:09:32,000 --> 00:09:39,000
|
| 487 |
+
This is just an additional food for thought for you in case you are interested about software architecture.
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:09:39,000 --> 00:09:44,000
|
| 491 |
+
So the implementation of the default rule facade is pretty straightforward.
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:09:44,000 --> 00:09:49,000
|
| 495 |
+
The next file that we updated is default user facade.
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:09:49,000 --> 00:09:58,000
|
| 499 |
+
I've removed setting role name here and instead I added setting array of roles, taking into account
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:09:58,000 --> 00:10:01,000
|
| 503 |
+
that we can register only user with a customer role.
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:10:01,000 --> 00:10:07,000
|
| 507 |
+
You can see here that I passed the array of roles that contains only one element.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:10:07,000 --> 00:10:08,000
|
| 511 |
+
Customer role.
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:10:09,000 --> 00:10:16,000
|
| 515 |
+
I added spring security core dependency in order to use password encoder in persistence module.
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:10:17,000 --> 00:10:21,000
|
| 519 |
+
The next file that you can see here in the list is the setup data loader.
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:10:21,000 --> 00:10:27,000
|
| 523 |
+
If you watched our lessons attentively, we already had this similar file in our code examples during
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:10:27,000 --> 00:10:28,000
|
| 527 |
+
the previous lessons.
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:10:28,000 --> 00:10:33,000
|
| 531 |
+
We are using it to configure privileges admin and manager users.
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:10:33,000 --> 00:10:39,000
|
| 535 |
+
I will not make a detailed overview of this file because we already did the detailed overview of this
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:10:39,000 --> 00:10:47,000
|
| 539 |
+
file during one of the coding exercises in the lesson, when we learned how to work with roles and privileges.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:10:47,000 --> 00:10:54,000
|
| 543 |
+
Basically just create or just check that all required roles, privileges and admin users exist in the
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:10:54,000 --> 00:11:01,000
|
| 547 |
+
system and you can see that this class implements application listener of context refreshed event.
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:11:01,000 --> 00:11:06,000
|
| 551 |
+
That means that mass will be triggered on the event of the context refresh.
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:11:07,000 --> 00:11:11,000
|
| 555 |
+
In this solution I introduced new entity privilege.
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:11:11,000 --> 00:11:17,000
|
| 559 |
+
That means that I need to create and implement all the related classes to support operations with this
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:11:17,000 --> 00:11:18,000
|
| 563 |
+
entity.
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:11:18,000 --> 00:11:25,000
|
| 567 |
+
This includes privilege, DAO, privilege, DTO privilege, business entity and privilege detail to
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:11:25,000 --> 00:11:27,000
|
| 571 |
+
privilege business model converter.
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:11:27,000 --> 00:11:34,000
|
| 575 |
+
Here you can see I declared two masses in the privilege DAO interface in the role Dao.
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:11:34,000 --> 00:11:37,000
|
| 579 |
+
I declared one more method safe.
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:11:37,000 --> 00:11:43,000
|
| 583 |
+
It is required for us to create all required roles from the setup data loader class.
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:11:43,000 --> 00:11:48,000
|
| 587 |
+
The next thing here in the list is the implementation of the privilege.
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:11:48,000 --> 00:11:50,000
|
| 591 |
+
Dao privilege.
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:11:50,000 --> 00:11:55,000
|
| 595 |
+
Dao implements a contract using the entity manager factory and entity manager.
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:11:56,000 --> 00:11:58,000
|
| 599 |
+
Also we slightly updated role DAO.
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:11:59,000 --> 00:12:06,000
|
| 603 |
+
I fixed a typo in the class name changed role name attribute and implemented safe method.
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:12:06,000 --> 00:12:12,000
|
| 607 |
+
Again, this is something that you have to be familiar with because we learned literally the similar
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:12:12,000 --> 00:12:15,000
|
| 611 |
+
examples in lessons about GPA.
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:12:15,000 --> 00:12:21,000
|
| 615 |
+
In case you want to refresh your knowledge, feel free to check my course Java from zero to first job
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:12:21,000 --> 00:12:24,000
|
| 619 |
+
and name the section about GPA Hibernate.
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:12:24,000 --> 00:12:26,000
|
| 623 |
+
Let's move on.
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:12:26,000 --> 00:12:29,000
|
| 627 |
+
Here you can see privileged class.
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:12:29,000 --> 00:12:37,000
|
| 631 |
+
And again, I just use the examples that I have shared with you in one of our lessons from this course.
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:12:37,000 --> 00:12:43,000
|
| 635 |
+
So it contains ID, name and list of roles in the role detail.
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:12:43,000 --> 00:12:45,000
|
| 639 |
+
I added privileges property.
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:12:45,000 --> 00:12:50,000
|
| 643 |
+
It is many to many relation and you can see list of privileges here.
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:12:50,000 --> 00:12:53,000
|
| 647 |
+
The rest is just getters and setters.
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:12:54,000 --> 00:13:02,000
|
| 651 |
+
Also, I made changes in the user class configure it many to many relationship with the roles.
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:13:02,000 --> 00:13:05,000
|
| 655 |
+
Also I added is enabled flag.
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:13:05,000 --> 00:13:11,000
|
| 659 |
+
It is not mandatory according to the task requirements, but I just decided to add it for the future.
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:13:11,000 --> 00:13:18,000
|
| 663 |
+
Probably we will implement with you security from the brute force and will disable account in case of
|
| 664 |
+
|
| 665 |
+
167
|
| 666 |
+
00:13:18,000 --> 00:13:22,000
|
| 667 |
+
multiple failed login attempts or things like that.
|
| 668 |
+
|
| 669 |
+
168
|
| 670 |
+
00:13:22,000 --> 00:13:28,000
|
| 671 |
+
Anyway, you can just turn on your imagination and come up with different similar business requirements.
|
| 672 |
+
|
| 673 |
+
169
|
| 674 |
+
00:13:29,000 --> 00:13:30,000
|
| 675 |
+
I leave it here.
|
| 676 |
+
|
| 677 |
+
170
|
| 678 |
+
00:13:31,000 --> 00:13:35,000
|
| 679 |
+
The next class here in the list is a converter class.
|
| 680 |
+
|
| 681 |
+
171
|
| 682 |
+
00:13:35,000 --> 00:13:40,000
|
| 683 |
+
It is required to convert privilege to privilege business model.
|
| 684 |
+
|
| 685 |
+
172
|
| 686 |
+
00:13:40,000 --> 00:13:48,000
|
| 687 |
+
Also based on the changes that we did in the raw entity, I also need to update row to row converter
|
| 688 |
+
|
| 689 |
+
173
|
| 690 |
+
00:13:48,000 --> 00:13:51,000
|
| 691 |
+
and user to user converter.
|
| 692 |
+
|
| 693 |
+
174
|
| 694 |
+
00:13:52,000 --> 00:13:57,000
|
| 695 |
+
The next thing here in the list is privileged role and user types.
|
| 696 |
+
|
| 697 |
+
175
|
| 698 |
+
00:13:57,000 --> 00:14:04,000
|
| 699 |
+
And again, we just need to make proper changes to reflect changes in the relationships that we did
|
| 700 |
+
|
| 701 |
+
176
|
| 702 |
+
00:14:04,000 --> 00:14:05,000
|
| 703 |
+
in our architecture.
|
| 704 |
+
|
| 705 |
+
177
|
| 706 |
+
00:14:05,000 --> 00:14:12,000
|
| 707 |
+
Just to remind you that in this task we configured many to many relationships between role and privilege
|
| 708 |
+
|
| 709 |
+
178
|
| 710 |
+
00:14:12,000 --> 00:14:15,000
|
| 711 |
+
and between user and role entities.
|
| 712 |
+
|
| 713 |
+
179
|
| 714 |
+
00:14:16,000 --> 00:14:22,000
|
| 715 |
+
And after that goes implementation of these types namely default village.
|
| 716 |
+
|
| 717 |
+
180
|
| 718 |
+
00:14:22,000 --> 00:14:24,000
|
| 719 |
+
Default role and default user.
|
| 720 |
+
|
| 721 |
+
181
|
| 722 |
+
00:14:25,000 --> 00:14:31,000
|
| 723 |
+
This is exactly our business entities where we can put any business related behavior associated with
|
| 724 |
+
|
| 725 |
+
182
|
| 726 |
+
00:14:31,000 --> 00:14:33,000
|
| 727 |
+
these entities.
|
| 728 |
+
|
| 729 |
+
183
|
| 730 |
+
00:14:33,000 --> 00:14:39,000
|
| 731 |
+
In Pom.xml I added all necessary dependencies to work with spring security.
|
| 732 |
+
|
| 733 |
+
184
|
| 734 |
+
00:14:40,000 --> 00:14:46,000
|
| 735 |
+
And the web application initializer add spring security filter to the select context.
|
| 736 |
+
|
| 737 |
+
185
|
| 738 |
+
00:14:46,000 --> 00:14:53,000
|
| 739 |
+
In the next file in the web.config, I created all necessary beans required for implementation of our
|
| 740 |
+
|
| 741 |
+
186
|
| 742 |
+
00:14:53,000 --> 00:14:54,000
|
| 743 |
+
task.
|
| 744 |
+
|
| 745 |
+
187
|
| 746 |
+
00:14:54,000 --> 00:15:01,000
|
| 747 |
+
First of all, this is password encoder that we are going to use for password encoding and verification
|
| 748 |
+
|
| 749 |
+
188
|
| 750 |
+
00:15:01,000 --> 00:15:06,000
|
| 751 |
+
of the raw password with its encoded version during the login.
|
| 752 |
+
|
| 753 |
+
189
|
| 754 |
+
00:15:06,000 --> 00:15:10,000
|
| 755 |
+
The next bin is the authentication success handler.
|
| 756 |
+
|
| 757 |
+
190
|
| 758 |
+
00:15:10,000 --> 00:15:13,000
|
| 759 |
+
We are going to review implementation a little bit later.
|
| 760 |
+
|
| 761 |
+
191
|
| 762 |
+
00:15:13,000 --> 00:15:20,000
|
| 763 |
+
In short, I will use it for putting user into session and configuring redirection based on the roles
|
| 764 |
+
|
| 765 |
+
192
|
| 766 |
+
00:15:20,000 --> 00:15:21,000
|
| 767 |
+
assigned.
|
| 768 |
+
|
| 769 |
+
193
|
| 770 |
+
00:15:22,000 --> 00:15:30,000
|
| 771 |
+
Then we have configuration of the security filter chain authorization of requests, custom login form.
|
| 772 |
+
|
| 773 |
+
194
|
| 774 |
+
00:15:30,000 --> 00:15:31,000
|
| 775 |
+
Pay attention.
|
| 776 |
+
|
| 777 |
+
195
|
| 778 |
+
00:15:31,000 --> 00:15:34,000
|
| 779 |
+
I change the name of the username parameter.
|
| 780 |
+
|
| 781 |
+
196
|
| 782 |
+
00:15:34,000 --> 00:15:41,000
|
| 783 |
+
As you remember, in case you use custom attribute name for username in the login form, you need to
|
| 784 |
+
|
| 785 |
+
197
|
| 786 |
+
00:15:41,000 --> 00:15:44,000
|
| 787 |
+
specify it in the configuration.
|
| 788 |
+
|
| 789 |
+
198
|
| 790 |
+
00:15:44,000 --> 00:15:49,000
|
| 791 |
+
And in my case I decided not to change existing login form.
|
| 792 |
+
|
| 793 |
+
199
|
| 794 |
+
00:15:49,000 --> 00:15:53,000
|
| 795 |
+
An existing form uses email name parameter.
|
| 796 |
+
|
| 797 |
+
200
|
| 798 |
+
00:15:54,000 --> 00:15:58,000
|
| 799 |
+
I said success handler and failure handler.
|
| 800 |
+
|
| 801 |
+
201
|
| 802 |
+
00:15:58,000 --> 00:16:04,000
|
| 803 |
+
Failure handler is used to limit failed amount of the attempts to login with the same period of time.
|
| 804 |
+
|
| 805 |
+
202
|
| 806 |
+
00:16:04,000 --> 00:16:08,000
|
| 807 |
+
We are going to review implementation a little bit later.
|
| 808 |
+
|
| 809 |
+
203
|
| 810 |
+
00:16:08,000 --> 00:16:12,000
|
| 811 |
+
Actually, it was already implemented in the template of the code.
|
| 812 |
+
|
| 813 |
+
204
|
| 814 |
+
00:16:13,000 --> 00:16:18,000
|
| 815 |
+
I just took it from the in controller and moved it into failure handler.
|
| 816 |
+
|
| 817 |
+
205
|
| 818 |
+
00:16:18,000 --> 00:16:21,000
|
| 819 |
+
Configure it, log out and remember me feature.
|
| 820 |
+
|
| 821 |
+
206
|
| 822 |
+
00:16:22,000 --> 00:16:28,000
|
| 823 |
+
Remember me configuration used literally in the same way like I showed you in the lesson about Remember
|
| 824 |
+
|
| 825 |
+
207
|
| 826 |
+
00:16:28,000 --> 00:16:29,000
|
| 827 |
+
Me functionality.
|
| 828 |
+
|
| 829 |
+
208
|
| 830 |
+
00:16:30,000 --> 00:16:32,000
|
| 831 |
+
The next bin is failure Handler.
|
| 832 |
+
|
| 833 |
+
209
|
| 834 |
+
00:16:32,000 --> 00:16:36,000
|
| 835 |
+
We are going to review its implementation soon.
|
| 836 |
+
|
| 837 |
+
210
|
| 838 |
+
00:16:37,000 --> 00:16:42,000
|
| 839 |
+
Also user details, service authentication provider and registration of the authentication provider
|
| 840 |
+
|
| 841 |
+
211
|
| 842 |
+
00:16:42,000 --> 00:16:45,000
|
| 843 |
+
in the authentication manager.
|
| 844 |
+
|
| 845 |
+
212
|
| 846 |
+
00:16:45,000 --> 00:16:48,000
|
| 847 |
+
Admin controller is the next file in the list.
|
| 848 |
+
|
| 849 |
+
213
|
| 850 |
+
00:16:48,000 --> 00:16:50,000
|
| 851 |
+
This is just simple controller.
|
| 852 |
+
|
| 853 |
+
214
|
| 854 |
+
00:16:50,000 --> 00:16:56,000
|
| 855 |
+
In order to resolve admin panel view that according to requirements should be protected.
|
| 856 |
+
|
| 857 |
+
215
|
| 858 |
+
00:16:57,000 --> 00:17:03,000
|
| 859 |
+
There are no specific requirements to this panel in general, and this particular exam task will practice
|
| 860 |
+
|
| 861 |
+
216
|
| 862 |
+
00:17:03,000 --> 00:17:06,000
|
| 863 |
+
our skills and configuration of the spring security.
|
| 864 |
+
|
| 865 |
+
217
|
| 866 |
+
00:17:07,000 --> 00:17:10,000
|
| 867 |
+
That's why the simple page is enough.
|
| 868 |
+
|
| 869 |
+
218
|
| 870 |
+
00:17:10,000 --> 00:17:12,000
|
| 871 |
+
In the edit profile controller.
|
| 872 |
+
|
| 873 |
+
219
|
| 874 |
+
00:17:12,000 --> 00:17:20,000
|
| 875 |
+
I also made some changes because it used as encoder and now inject password encoder being that we declared.
|
| 876 |
+
|
| 877 |
+
220
|
| 878 |
+
00:17:21,000 --> 00:17:28,000
|
| 879 |
+
I removed a lot from the sign in controller because part of the functionality described here goes to
|
| 880 |
+
|
| 881 |
+
221
|
| 882 |
+
00:17:28,000 --> 00:17:29,000
|
| 883 |
+
the spring security.
|
| 884 |
+
|
| 885 |
+
222
|
| 886 |
+
00:17:29,000 --> 00:17:36,000
|
| 887 |
+
Another part of the functionality is moved into authentication success handler and the last part of
|
| 888 |
+
|
| 889 |
+
223
|
| 890 |
+
00:17:36,000 --> 00:17:40,000
|
| 891 |
+
the functionality is moved into the authentication failure handler.
|
| 892 |
+
|
| 893 |
+
224
|
| 894 |
+
00:17:41,000 --> 00:17:45,000
|
| 895 |
+
Signout controller was removed because we don't need it.
|
| 896 |
+
|
| 897 |
+
225
|
| 898 |
+
00:17:45,000 --> 00:17:53,000
|
| 899 |
+
Spring security will take care of Signout and we configure it Signout already in signup controller.
|
| 900 |
+
|
| 901 |
+
226
|
| 902 |
+
00:17:53,000 --> 00:18:01,000
|
| 903 |
+
I also had to make changes in order to inject password and quarter bean and use its API.
|
| 904 |
+
|
| 905 |
+
227
|
| 906 |
+
00:18:01,000 --> 00:18:06,000
|
| 907 |
+
Admin filter and management filter were removed because right now there is no need in them.
|
| 908 |
+
|
| 909 |
+
228
|
| 910 |
+
00:18:07,000 --> 00:18:11,000
|
| 911 |
+
Authentication is performed by the spring security now.
|
| 912 |
+
|
| 913 |
+
229
|
| 914 |
+
00:18:12,000 --> 00:18:15,000
|
| 915 |
+
Remember me filter is important and interesting.
|
| 916 |
+
|
| 917 |
+
230
|
| 918 |
+
00:18:15,000 --> 00:18:18,000
|
| 919 |
+
One let me explain you why we need it.
|
| 920 |
+
|
| 921 |
+
231
|
| 922 |
+
00:18:18,000 --> 00:18:26,000
|
| 923 |
+
So as you may notice, some behavior in the application relies on the presence of the user in the session.
|
| 924 |
+
|
| 925 |
+
232
|
| 926 |
+
00:18:26,000 --> 00:18:34,000
|
| 927 |
+
Namely, we need to hide signing button in the header in case user is logged in and show his name.
|
| 928 |
+
|
| 929 |
+
233
|
| 930 |
+
00:18:34,000 --> 00:18:42,000
|
| 931 |
+
And also we need to hide sign up button in case user is logged in and to show sign out button instead
|
| 932 |
+
|
| 933 |
+
234
|
| 934 |
+
00:18:42,000 --> 00:18:50,000
|
| 935 |
+
we implemented Remember Me feature in the scenario when I close the web browser and open it again based
|
| 936 |
+
|
| 937 |
+
235
|
| 938 |
+
00:18:50,000 --> 00:18:59,000
|
| 939 |
+
on the cookie set application authenticates our user, but the session is actually destroyed and new
|
| 940 |
+
|
| 941 |
+
236
|
| 942 |
+
00:18:59,000 --> 00:19:00,000
|
| 943 |
+
one is created.
|
| 944 |
+
|
| 945 |
+
237
|
| 946 |
+
00:19:00,000 --> 00:19:09,000
|
| 947 |
+
So this filter intercepts all the requests in case there is no user in the session configured, I check
|
| 948 |
+
|
| 949 |
+
238
|
| 950 |
+
00:19:09,000 --> 00:19:16,000
|
| 951 |
+
whether there is somebody authenticated in the security context holder and in case there is somebody
|
| 952 |
+
|
| 953 |
+
239
|
| 954 |
+
00:19:16,000 --> 00:19:22,000
|
| 955 |
+
authenticated, we get this user by email from the persistent storage and we set it into the session.
|
| 956 |
+
|
| 957 |
+
240
|
| 958 |
+
00:19:22,000 --> 00:19:24,000
|
| 959 |
+
That's it.
|
| 960 |
+
|
| 961 |
+
241
|
| 962 |
+
00:19:24,000 --> 00:19:31,000
|
| 963 |
+
Another challenge that you may face with in general with injecting beans into the web filters because
|
| 964 |
+
|
| 965 |
+
242
|
| 966 |
+
00:19:31,000 --> 00:19:39,000
|
| 967 |
+
of the way how initialization happens, you can't inject beans by simply putting auto wired annotation.
|
| 968 |
+
|
| 969 |
+
243
|
| 970 |
+
00:19:40,000 --> 00:19:47,000
|
| 971 |
+
One of the possible ways of how to initialize a property with the bin that you want is to get the reference
|
| 972 |
+
|
| 973 |
+
244
|
| 974 |
+
00:19:47,000 --> 00:19:51,000
|
| 975 |
+
to the application context and extract bin from it.
|
| 976 |
+
|
| 977 |
+
245
|
| 978 |
+
00:19:51,000 --> 00:19:53,000
|
| 979 |
+
How to do this?
|
| 980 |
+
|
| 981 |
+
246
|
| 982 |
+
00:19:53,000 --> 00:20:00,000
|
| 983 |
+
You can see in these lines, the next class here is a default authentication failure handler.
|
| 984 |
+
|
| 985 |
+
247
|
| 986 |
+
00:20:00,000 --> 00:20:07,000
|
| 987 |
+
And as already mentioned before, this code is part of the code that I took from the sign in controller
|
| 988 |
+
|
| 989 |
+
248
|
| 990 |
+
00:20:07,000 --> 00:20:09,000
|
| 991 |
+
of the project template.
|
| 992 |
+
|
| 993 |
+
249
|
| 994 |
+
00:20:09,000 --> 00:20:16,000
|
| 995 |
+
Taking into account that authentication is handled by the spring security, I need to put some part
|
| 996 |
+
|
| 997 |
+
250
|
| 998 |
+
00:20:16,000 --> 00:20:18,000
|
| 999 |
+
of logic into the event handlers.
|
| 1000 |
+
|
| 1001 |
+
251
|
| 1002 |
+
00:20:19,000 --> 00:20:26,000
|
| 1003 |
+
Namely, in this handler, I handle cases of the failure during the authentication in case there will
|
| 1004 |
+
|
| 1005 |
+
252
|
| 1006 |
+
00:20:26,000 --> 00:20:32,000
|
| 1007 |
+
be three unsuccessful attempts of login, we update the variable of the unsuccessful login in order
|
| 1008 |
+
|
| 1009 |
+
253
|
| 1010 |
+
00:20:32,000 --> 00:20:38,000
|
| 1011 |
+
to prevent brute force and stop wrong usage of the web application.
|
| 1012 |
+
|
| 1013 |
+
254
|
| 1014 |
+
00:20:38,000 --> 00:20:42,000
|
| 1015 |
+
His next file here is a authentication success handler.
|
| 1016 |
+
|
| 1017 |
+
255
|
| 1018 |
+
00:20:42,000 --> 00:20:50,000
|
| 1019 |
+
The purpose of this handler, first of all, is to make sure that we put user into the session in order
|
| 1020 |
+
|
| 1021 |
+
256
|
| 1022 |
+
00:20:50,000 --> 00:20:57,000
|
| 1023 |
+
to use it later in the application during the purchase flow and other business related actions, and
|
| 1024 |
+
|
| 1025 |
+
257
|
| 1026 |
+
00:20:57,000 --> 00:21:03,000
|
| 1027 |
+
taking into account that redirection to the configured success here doesn't work when we declare a success
|
| 1028 |
+
|
| 1029 |
+
258
|
| 1030 |
+
00:21:03,000 --> 00:21:04,000
|
| 1031 |
+
handler.
|
| 1032 |
+
|
| 1033 |
+
259
|
| 1034 |
+
00:21:04,000 --> 00:21:12,000
|
| 1035 |
+
Considering this, I also need to manage redirection of the user based on their roles in this event
|
| 1036 |
+
|
| 1037 |
+
260
|
| 1038 |
+
00:21:12,000 --> 00:21:12,000
|
| 1039 |
+
handler.
|
| 1040 |
+
|
| 1041 |
+
261
|
| 1042 |
+
00:21:13,000 --> 00:21:19,000
|
| 1043 |
+
So users with the admin role are redirected to the admin panel and all other users are redirected to
|
| 1044 |
+
|
| 1045 |
+
262
|
| 1046 |
+
00:21:19,000 --> 00:21:22,000
|
| 1047 |
+
the home page according to our requirements.
|
| 1048 |
+
|
| 1049 |
+
263
|
| 1050 |
+
00:21:23,000 --> 00:21:26,000
|
| 1051 |
+
Default authentication provider.
|
| 1052 |
+
|
| 1053 |
+
264
|
| 1054 |
+
00:21:26,000 --> 00:21:30,000
|
| 1055 |
+
I used the same that we used and reviewed in the lesson.
|
| 1056 |
+
|
| 1057 |
+
265
|
| 1058 |
+
00:21:30,000 --> 00:21:35,000
|
| 1059 |
+
Just checking username and password and returning authentication object.
|
| 1060 |
+
|
| 1061 |
+
266
|
| 1062 |
+
00:21:36,000 --> 00:21:40,000
|
| 1063 |
+
The fork user details service almost the similar story.
|
| 1064 |
+
|
| 1065 |
+
267
|
| 1066 |
+
00:21:40,000 --> 00:21:43,000
|
| 1067 |
+
I took the same implementation that I used in the lesson.
|
| 1068 |
+
|
| 1069 |
+
268
|
| 1070 |
+
00:21:44,000 --> 00:21:47,000
|
| 1071 |
+
I believe there is no need for me to repeat myself on everything.
|
| 1072 |
+
|
| 1073 |
+
269
|
| 1074 |
+
00:21:47,000 --> 00:21:53,000
|
| 1075 |
+
What we have reviewed in the lessons because in this case the length of this video will be the summary
|
| 1076 |
+
|
| 1077 |
+
270
|
| 1078 |
+
00:21:53,000 --> 00:21:55,000
|
| 1079 |
+
length of all previous lessons.
|
| 1080 |
+
|
| 1081 |
+
271
|
| 1082 |
+
00:21:55,000 --> 00:22:00,000
|
| 1083 |
+
Feel free to get back to the previous lessons in case you want to refresh your knowledge.
|
| 1084 |
+
|
| 1085 |
+
272
|
| 1086 |
+
00:22:00,000 --> 00:22:07,000
|
| 1087 |
+
And in this video I will focus only on the specifics of the implementation of the application.
|
| 1088 |
+
|
| 1089 |
+
273
|
| 1090 |
+
00:22:08,000 --> 00:22:14,000
|
| 1091 |
+
I removed and quarters that we used in the previous solution because now we are going to use password
|
| 1092 |
+
|
| 1093 |
+
274
|
| 1094 |
+
00:22:14,000 --> 00:22:23,000
|
| 1095 |
+
encoder been added some changes in the profile personal tag taking into account we have array of roles
|
| 1096 |
+
|
| 1097 |
+
275
|
| 1098 |
+
00:22:23,000 --> 00:22:24,000
|
| 1099 |
+
associated with the user.
|
| 1100 |
+
|
| 1101 |
+
276
|
| 1102 |
+
00:22:24,000 --> 00:22:28,000
|
| 1103 |
+
Let's not display all the possible role names.
|
| 1104 |
+
|
| 1105 |
+
277
|
| 1106 |
+
00:22:28,000 --> 00:22:31,000
|
| 1107 |
+
Here is the template file for admin panel.
|
| 1108 |
+
|
| 1109 |
+
278
|
| 1110 |
+
00:22:31,000 --> 00:22:38,000
|
| 1111 |
+
So team, the main thing for us is to practice our skills in the configuration of the spring security.
|
| 1112 |
+
|
| 1113 |
+
279
|
| 1114 |
+
00:22:38,000 --> 00:22:43,000
|
| 1115 |
+
That's why there is not so much JavaScript or anything else on this page.
|
| 1116 |
+
|
| 1117 |
+
280
|
| 1118 |
+
00:22:43,000 --> 00:22:49,000
|
| 1119 |
+
It exists just for you to practice in configuring access to the admin resources.
|
| 1120 |
+
|
| 1121 |
+
281
|
| 1122 |
+
00:22:50,000 --> 00:22:54,000
|
| 1123 |
+
Also, I introduced improvements in the not found page.
|
| 1124 |
+
|
| 1125 |
+
282
|
| 1126 |
+
00:22:54,000 --> 00:23:02,000
|
| 1127 |
+
I used the URL from the core STL in order to not have problems with the relative paths in case Page
|
| 1128 |
+
|
| 1129 |
+
283
|
| 1130 |
+
00:23:02,000 --> 00:23:08,000
|
| 1131 |
+
is not found, not in the root of our application, but in some other places.
|
| 1132 |
+
|
| 1133 |
+
284
|
| 1134 |
+
00:23:08,000 --> 00:23:15,000
|
| 1135 |
+
Because previously we had issues with not being able to find required CSS resources using relative paths.
|
| 1136 |
+
|
| 1137 |
+
285
|
| 1138 |
+
00:23:16,000 --> 00:23:22,000
|
| 1139 |
+
This improvement is not specified directly in the requirements of the exam task.
|
| 1140 |
+
|
| 1141 |
+
286
|
| 1142 |
+
00:23:22,000 --> 00:23:29,000
|
| 1143 |
+
I just gradually improve our solution in case I found something strange or typos like here, for example.
|
| 1144 |
+
|
| 1145 |
+
287
|
| 1146 |
+
00:23:30,000 --> 00:23:36,000
|
| 1147 |
+
Because our goal is to make completely ready to use online shop by the end of the course.
|
| 1148 |
+
|
| 1149 |
+
288
|
| 1150 |
+
00:23:36,000 --> 00:23:38,000
|
| 1151 |
+
Java from zero to first job.
|
| 1152 |
+
|
| 1153 |
+
289
|
| 1154 |
+
00:23:39,000 --> 00:23:45,000
|
| 1155 |
+
On the sign in page, I added Remember me checkbox and updated action in my form.
|
| 1156 |
+
|
| 1157 |
+
290
|
| 1158 |
+
00:23:45,000 --> 00:23:48,000
|
| 1159 |
+
According to the configuration defined.
|
| 1160 |
+
|
| 1161 |
+
291
|
| 1162 |
+
00:23:48,000 --> 00:23:56,000
|
| 1163 |
+
Also, I fixed type in the template project because for the password it is recommended to use password
|
| 1164 |
+
|
| 1165 |
+
292
|
| 1166 |
+
00:23:56,000 --> 00:23:58,000
|
| 1167 |
+
element for the security reasons.
|
| 1168 |
+
|
| 1169 |
+
293
|
| 1170 |
+
00:23:59,000 --> 00:24:06,000
|
| 1171 |
+
I've removed redundant sinks from the web.xml and also I had to adjust the styling for the checkbox
|
| 1172 |
+
|
| 1173 |
+
294
|
| 1174 |
+
00:24:06,000 --> 00:24:12,000
|
| 1175 |
+
because opacity was set to zero and absolute position was a shift to the left.
|
| 1176 |
+
|
| 1177 |
+
295
|
| 1178 |
+
00:24:13,000 --> 00:24:19,000
|
| 1179 |
+
So without commenting these styles in the style CSS, you won't be able to see the checkbox that you
|
| 1180 |
+
|
| 1181 |
+
296
|
| 1182 |
+
00:24:19,000 --> 00:24:21,000
|
| 1183 |
+
put on the sign in page.
|
| 1184 |
+
|
| 1185 |
+
297
|
| 1186 |
+
00:24:22,000 --> 00:24:23,000
|
| 1187 |
+
Be attentive.
|
| 1188 |
+
|
| 1189 |
+
298
|
| 1190 |
+
00:24:23,000 --> 00:24:26,000
|
| 1191 |
+
I also made checkbox slightly bigger.
|
| 1192 |
+
|
| 1193 |
+
299
|
| 1194 |
+
00:24:27,000 --> 00:24:31,000
|
| 1195 |
+
Basically that's all solutions that I've implemented.
|
| 1196 |
+
|
| 1197 |
+
300
|
| 1198 |
+
00:24:32,000 --> 00:24:38,000
|
| 1199 |
+
And remember, in programming, especially on such advanced level and using such flexible framework
|
| 1200 |
+
|
| 1201 |
+
301
|
| 1202 |
+
00:24:38,000 --> 00:24:43,000
|
| 1203 |
+
as spring, there are always multiple solutions to solve the same task.
|
| 1204 |
+
|
| 1205 |
+
302
|
| 1206 |
+
00:24:43,000 --> 00:24:50,000
|
| 1207 |
+
So don't worry in case your implementation is slightly different, no need to worry about that is also
|
| 1208 |
+
|
| 1209 |
+
303
|
| 1210 |
+
00:24:50,000 --> 00:24:56,000
|
| 1211 |
+
fine because like I said, there are multiple possible solutions of the same task.
|
| 1212 |
+
|
| 1213 |
+
304
|
| 1214 |
+
00:24:57,000 --> 00:25:04,000
|
| 1215 |
+
I'm sure that this learning module was super useful for you, and we learned really a lot of things.
|
| 1216 |
+
|
| 1217 |
+
305
|
| 1218 |
+
00:25:04,000 --> 00:25:11,000
|
| 1219 |
+
After completion of this exam task, you can consider yourself as professional in spring security.
|
| 1220 |
+
|
| 1221 |
+
306
|
| 1222 |
+
00:25:11,000 --> 00:25:13,000
|
| 1223 |
+
Congratulations with this.
|
| 1224 |
+
|
| 1225 |
+
307
|
| 1226 |
+
00:25:13,000 --> 00:25:20,000
|
| 1227 |
+
And always remember that in case you have any questions, you can put them below the video and I will
|
| 1228 |
+
|
| 1229 |
+
308
|
| 1230 |
+
00:25:20,000 --> 00:25:21,000
|
| 1231 |
+
be happy to answer.
|
| 1232 |
+
|
| 1233 |
+
309
|
| 1234 |
+
00:25:22,000 --> 00:25:24,000
|
| 1235 |
+
So thanks a lot for your attention.
|
| 1236 |
+
|
| 1237 |
+
310
|
| 1238 |
+
00:25:25,000 --> 00:25:28,000
|
| 1239 |
+
We should agree today and see you in the next lesson.
|
| 1240 |
+
|
85 - ===== EXAM Spring Security - Online Shop =====/001 Exam-task-description-with-the-reference-to-the-solution.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://docs.google.com/document/d/1HjR-heOVqGgGVdtqf1_5r_T21Ax45lynDktLJzngHTU/edit?usp=sharing
|
85 - ===== EXAM Spring Security - Online Shop =====/external-links.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
001 Exam-task-description-with-the-reference-to-the-solution
|
| 3 |
+
https://docs.google.com/document/d/1HjR-heOVq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|
+
1
|
| 2 |
+
00:00:05,000 --> 00:00:06,000
|
| 3 |
+
Hello, team.
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:06,000 --> 00:00:09,000
|
| 7 |
+
Welcome to the first lesson of the new module.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:09,000 --> 00:00:16,000
|
| 11 |
+
We are continuing learning spring framework and with this lesson we start learning of the Spring data
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:16,000 --> 00:00:17,000
|
| 15 |
+
module.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:17,000 --> 00:00:24,000
|
| 19 |
+
In this first video we are going to learn what is spring data is we will make an overview in order.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:24,000 --> 00:00:27,000
|
| 23 |
+
You can understand what it is.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:27,000 --> 00:00:34,000
|
| 27 |
+
We will learn what spring data modules exists and we will focus our attention on the review of the Spring
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:34,000 --> 00:00:36,000
|
| 31 |
+
Data JPA module.
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:36,000 --> 00:00:42,000
|
| 35 |
+
You are going to understand the challenge that spring data JPA is supposed to help us with.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:43,000 --> 00:00:46,000
|
| 39 |
+
I will explain what spring data repositories are.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:46,000 --> 00:00:53,000
|
| 43 |
+
Also, we'll talk about repository pattern and at the end of the lesson we are going to use spring data,
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:53,000 --> 00:00:55,000
|
| 47 |
+
JPA advantages and disadvantages.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:55,000 --> 00:01:01,000
|
| 51 |
+
This will be introductory lessons that will give you more context before we jump to practical coding
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:01:01,000 --> 00:01:06,000
|
| 55 |
+
exercises in the following lessons, let's start our lesson.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:01:06,000 --> 00:01:11,000
|
| 59 |
+
Let's start with a brief overview of what actually spring data is.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:01:11,000 --> 00:01:19,000
|
| 63 |
+
The spring data is an umbrella project, having many subprojects or modules to provide uniform abstractions
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:01:19,000 --> 00:01:27,000
|
| 67 |
+
and uniform utility methods for the data access layer in an application and supports a wide range of
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:01:27,000 --> 00:01:30,000
|
| 71 |
+
databases and data stores.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:01:30,000 --> 00:01:32,000
|
| 75 |
+
What kind of projects?
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:01:32,000 --> 00:01:33,000
|
| 79 |
+
For example?
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:01:33,000 --> 00:01:40,000
|
| 83 |
+
Data graph data, JDBC data, JPA data, Mongo data, Solr, etcetera.
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:01:40,000 --> 00:01:47,000
|
| 87 |
+
And it is important to understand that spring data is not a specification to implement or some kind
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:01:47,000 --> 00:01:48,000
|
| 91 |
+
of standard.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:01:48,000 --> 00:01:50,000
|
| 95 |
+
It is just an abstraction.
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:01:50,000 --> 00:01:57,000
|
| 99 |
+
It contains many different modules starting from the core Spring Data Commons module to specific ones
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:01:57,000 --> 00:02:01,000
|
| 103 |
+
like spring data radius, spring data, Mongo, etcetera.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:02:02,000 --> 00:02:08,000
|
| 107 |
+
The goal of this abstraction is to bring consistency between the ways we access data on multiple data
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:02:08,000 --> 00:02:14,000
|
| 111 |
+
stores, no matter whether we are talking about relational or NoSQL databases.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:02:14,000 --> 00:02:20,000
|
| 115 |
+
Another important thing to understand is to know what a spring data JPA is.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:02:20,000 --> 00:02:29,000
|
| 119 |
+
So as I already said, spring data is a common name that is used to group multiple sub projects and
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:02:29,000 --> 00:02:30,000
|
| 123 |
+
spring data.
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:02:30,000 --> 00:02:35,000
|
| 127 |
+
JPA is just one out of many other projects, but probably one of the most popular.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:02:35,000 --> 00:02:40,000
|
| 131 |
+
A lot of people saying that Spring Data JPA is a GP implementation.
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:02:40,000 --> 00:02:42,000
|
| 135 |
+
Actually, it is not.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:02:42,000 --> 00:02:48,000
|
| 139 |
+
In reality, Spring Data JPA uses hibernate GP implementation.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:02:48,000 --> 00:02:57,000
|
| 143 |
+
GPA is a specification that defines an API for object relational mappings and for managing persistent
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:02:57,000 --> 00:02:58,000
|
| 147 |
+
objects.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:02:58,000 --> 00:03:04,000
|
| 151 |
+
Hibernate and Eclipselink are two the most popular implementations of this specification and in the
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:03:04,000 --> 00:03:08,000
|
| 155 |
+
case spring data JPA is not a GP implementation.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:03:08,000 --> 00:03:14,000
|
| 159 |
+
Then what it is, we can say that spring Data JPA is an add on for GPA.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:03:15,000 --> 00:03:21,000
|
| 163 |
+
It provides a framework that works with GPA and provides a complete abstraction over the data access
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:03:21,000 --> 00:03:22,000
|
| 167 |
+
layer.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:03:22,000 --> 00:03:27,000
|
| 171 |
+
Taking into account that spring data JPA is add on on top of GPA.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:03:28,000 --> 00:03:36,000
|
| 175 |
+
It uses all features defined by the GPA specification, including entity mappings, lifecycle management
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:03:36,000 --> 00:03:39,000
|
| 179 |
+
and GPA query capabilities.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:03:39,000 --> 00:03:47,000
|
| 183 |
+
And on top of that, spring data, JPA adds its own features like no code implementation of the DAO
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:03:47,000 --> 00:03:51,000
|
| 187 |
+
and creation of database queries from the method names.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:03:51,000 --> 00:03:56,000
|
| 191 |
+
We are going to start learning the spring data from the Spring Data JPA module.
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:03:57,000 --> 00:04:02,000
|
| 195 |
+
To begin with, let's understand the problem that we are going to address with the spring data.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:04:02,000 --> 00:04:09,000
|
| 199 |
+
If you are a student of my course Java from zero to first job and you learned DAO pattern in one of
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:04:09,000 --> 00:04:17,000
|
| 203 |
+
the lessons, then you already realize what does it mean to define interface for DAO to implement it
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:04:17,000 --> 00:04:24,000
|
| 207 |
+
and you have multiple entities and also in case you want to switch to another database, for example,
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:04:24,000 --> 00:04:29,000
|
| 211 |
+
from relational to Non-relational, you need to implement all those again.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:04:29,000 --> 00:04:33,000
|
| 215 |
+
And imagine doing this for all entities in your application.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:04:33,000 --> 00:04:41,000
|
| 219 |
+
It is really big amount of code and it is good in case you don't have too much entities, but in case
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:04:41,000 --> 00:04:48,000
|
| 223 |
+
you have a lot of models, you feel all the pain and most of the code looks similar.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:04:49,000 --> 00:04:51,000
|
| 227 |
+
What if we could simplify this?
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:04:51,000 --> 00:04:59,000
|
| 231 |
+
There are a lot of advantages of such simplification, like, for example, decreasing the number of
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:04:59,000 --> 00:05:05,000
|
| 235 |
+
artifacts that we need to create and support consistency of data access patterns and consistency of
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:05:05,000 --> 00:05:10,000
|
| 239 |
+
configuration and spring data helps us to simplify this.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:05:10,000 --> 00:05:17,000
|
| 243 |
+
Spring data is going to address the challenge of the implementation of different DAO and their support.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:05:18,000 --> 00:05:19,000
|
| 247 |
+
Spring data.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:05:19,000 --> 00:05:22,000
|
| 251 |
+
JPA brings the concept of the repositories.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:05:23,000 --> 00:05:24,000
|
| 255 |
+
What are they?
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:05:25,000 --> 00:05:32,000
|
| 259 |
+
Repositories are a set of interfaces that define ready to use methods to work with the data from the
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:05:32,000 --> 00:05:33,000
|
| 263 |
+
repositories.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:05:33,000 --> 00:05:40,000
|
| 267 |
+
The JPA repository represents the layer in our application according to the concept.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:05:40,000 --> 00:05:46,000
|
| 271 |
+
You don't necessarily need to write queries anymore, but still you can.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:05:46,000 --> 00:05:52,000
|
| 275 |
+
And sometimes you have to write SQL queries using spring data JPA.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:05:52,000 --> 00:05:55,000
|
| 279 |
+
You don't need to write SQL statements.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:05:55,000 --> 00:06:01,000
|
| 283 |
+
So taking into account spring GPA uses hibernate GP implementation.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:06:01,000 --> 00:06:07,000
|
| 287 |
+
It uses entity manager for persistent and retrieving entities from the databases.
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:06:07,000 --> 00:06:11,000
|
| 291 |
+
It also enables entity object and their mappings.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:06:11,000 --> 00:06:19,000
|
| 295 |
+
So in order to understand how spring data JPA works, it is nice to have experience of working with
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:06:19,000 --> 00:06:20,000
|
| 299 |
+
Hibernate.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:06:20,000 --> 00:06:26,000
|
| 303 |
+
And in case you want to refresh your knowledge, I have a lot of detailed lessons about Hibernate in
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:06:26,000 --> 00:06:28,000
|
| 307 |
+
my course Java from zero to first job.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:06:29,000 --> 00:06:36,000
|
| 311 |
+
Now it is time to review advantages and disadvantages of Spring Data JPA and we are going to start with
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:06:36,000 --> 00:06:37,000
|
| 315 |
+
advantages.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:06:38,000 --> 00:06:45,000
|
| 319 |
+
The first advantage of the spring data JPA is its seamless integration with the rest of the spring framework.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:06:45,000 --> 00:06:52,000
|
| 323 |
+
Just imagine integration with all other spring based components in your application.
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:06:52,000 --> 00:06:55,000
|
| 327 |
+
Accessing property configurations.
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:06:55,000 --> 00:07:00,000
|
| 331 |
+
Auto wiring of the repositories into the application service layer.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:07:00,000 --> 00:07:06,000
|
| 335 |
+
When we will start learn Spring boot, you will understand how easily it is also configured in the spring
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:07:06,000 --> 00:07:11,000
|
| 339 |
+
boot where we only need to provide the data source details.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:07:12,000 --> 00:07:17,000
|
| 343 |
+
The next advantage that I already mentioned previously is no code repositories.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:07:17,000 --> 00:07:21,000
|
| 347 |
+
Spring Data JPA implements repository pattern.
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:07:21,000 --> 00:07:24,000
|
| 351 |
+
The repository pattern is pretty simple.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:07:24,000 --> 00:07:33,000
|
| 355 |
+
An interface defines the repository with all logical read and write operations for a specific entity.
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:07:33,000 --> 00:07:34,000
|
| 359 |
+
That's it.
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:07:35,000 --> 00:07:42,000
|
| 363 |
+
Implementing that pattern isn't too complicated, but writing the standard CRUD operations for each
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:07:42,000 --> 00:07:46,000
|
| 367 |
+
entity creates a lot of repetitive code.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:07:46,000 --> 00:07:54,000
|
| 371 |
+
Spring Data JPA provides you a set of repository interfaces which you only need to extend to define
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:07:54,000 --> 00:07:58,000
|
| 375 |
+
a specific repository for one of your entities.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:07:58,000 --> 00:08:03,000
|
| 379 |
+
On this slide, you can see example of the repository that can do the following things.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:08:04,000 --> 00:08:09,000
|
| 383 |
+
Persist update and remove one or multiple book entities.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:08:09,000 --> 00:08:14,000
|
| 387 |
+
Find one or more books by their primary keys.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:08:14,000 --> 00:08:15,000
|
| 391 |
+
Count.
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:08:15,000 --> 00:08:17,000
|
| 395 |
+
Get and remove all books.
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:08:18,000 --> 00:08:21,000
|
| 399 |
+
Check if a book with a given primary key exists.
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:08:22,000 --> 00:08:29,000
|
| 403 |
+
And yes, this is literally all the code that you need by extending CRUD repository.
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:08:29,000 --> 00:08:32,000
|
| 407 |
+
You can take advantage of spring data JPA.
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:08:33,000 --> 00:08:38,000
|
| 411 |
+
This is probably one of the most impressive and attractive feature of spring data JPA.
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:08:39,000 --> 00:08:43,000
|
| 415 |
+
The third advantage is reducing code.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:08:43,000 --> 00:08:49,000
|
| 419 |
+
Reducing the code means you also reduce the probability of bugs and mistakes.
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:08:49,000 --> 00:08:53,000
|
| 423 |
+
Also, it just makes your life a little bit easier.
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:08:54,000 --> 00:08:59,000
|
| 427 |
+
The next advantage is query generation based on the method names.
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:09:00,000 --> 00:09:07,000
|
| 431 |
+
This is a super interesting feature, even in case you don't have masses that you need in one of the
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:09:07,000 --> 00:09:09,000
|
| 435 |
+
predefined repositories.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:09:09,000 --> 00:09:17,000
|
| 439 |
+
You just need to name method in your interface according to pattern and required query will be automatically
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:09:17,000 --> 00:09:18,000
|
| 443 |
+
generated for you.
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:09:18,000 --> 00:09:19,000
|
| 447 |
+
Can you imagine that?
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:09:20,000 --> 00:09:23,000
|
| 451 |
+
For example, pay attention to the example on the slide.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:09:24,000 --> 00:09:30,000
|
| 455 |
+
In this case we defined method find by title with the string parameter.
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:09:30,000 --> 00:09:38,000
|
| 459 |
+
Now I can simply inject this repository in any class of the service layer and use the method to extract
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:09:38,000 --> 00:09:43,000
|
| 463 |
+
book by fieldname where field name will be called title.
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:09:43,000 --> 00:09:53,000
|
| 467 |
+
So we removed a lot of advantages and as experienced engineer IT director, I can sell spring data JPA
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:09:53,000 --> 00:09:54,000
|
| 471 |
+
when it is needed.
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:09:54,000 --> 00:10:01,000
|
| 475 |
+
But taking into account with this course, I want to share with you everything what I know.
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:10:01,000 --> 00:10:03,000
|
| 479 |
+
I will be completely honest with you.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:10:04,000 --> 00:10:07,000
|
| 483 |
+
Spring Data JPA has its own disadvantages.
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:10:08,000 --> 00:10:09,000
|
| 487 |
+
I will try to be short.
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:10:10,000 --> 00:10:17,000
|
| 491 |
+
We already learned that spring data is an addition layer above common technologies for storing data.
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:10:17,000 --> 00:10:25,000
|
| 495 |
+
Spring Data JPA is the most commonly used part of spring data is supposed to simplify GPU based code
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:10:25,000 --> 00:10:28,000
|
| 499 |
+
by eliminating recurrent pieces of code.
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:10:29,000 --> 00:10:37,000
|
| 503 |
+
But in reality, spring data JPA simplifies the code by sacrificing performance and flexibility sometimes.
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:10:37,000 --> 00:10:45,000
|
| 507 |
+
Also, it doesn't provide a lot of new things because it still uses hibernate and hidden entity manager.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:10:45,000 --> 00:10:53,000
|
| 511 |
+
So it looks like the key feature of spring data JPA is just to save time on writing code rather than
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:10:53,000 --> 00:10:59,000
|
| 515 |
+
to achieve better performance or optimization in the way how queries are generated.
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:11:00,000 --> 00:11:07,000
|
| 519 |
+
There is a thought that overall spring data JPA is the best suited for demo application with empty databases,
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:11:07,000 --> 00:11:11,000
|
| 523 |
+
primarily because of the performance concerns.
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:11:11,000 --> 00:11:19,000
|
| 527 |
+
Of course, the project is evolving and of course it is getting better with each release and each new
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:11:19,000 --> 00:11:23,000
|
| 531 |
+
version, you know, using spring data JPA or something else.
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:11:23,000 --> 00:11:26,000
|
| 535 |
+
It is just a matter of style and habit.
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:11:27,000 --> 00:11:31,000
|
| 539 |
+
Somebody likes cars with an automatic gearbox.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:11:31,000 --> 00:11:36,000
|
| 543 |
+
But I'm the guy who prefer to have manual gearbox in the programming.
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:11:36,000 --> 00:11:44,000
|
| 547 |
+
I like the granularity and control that I get with the JDBC, but I accept the fact that somebody may
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:11:44,000 --> 00:11:48,000
|
| 551 |
+
not like this as me, and that is fine.
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:11:48,000 --> 00:11:55,000
|
| 555 |
+
As I said, it is a matter of style and as professionals we need to know different ways to achieve the
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:11:55,000 --> 00:11:56,000
|
| 559 |
+
same goal.
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:11:56,000 --> 00:12:01,000
|
| 563 |
+
As you may already guess, I prefer JDBC and I'm not joking.
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:12:01,000 --> 00:12:08,000
|
| 567 |
+
You know that I am CEO of IT company and we have our own products, including mobile and web applications
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:12:08,000 --> 00:12:11,000
|
| 571 |
+
and because of many different reasons I still.
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:12:11,000 --> 00:12:13,000
|
| 575 |
+
Prefer using JDBC.
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:12:13,000 --> 00:12:18,000
|
| 579 |
+
If you just want to use spring, there is also spring data JDBC module.
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:12:18,000 --> 00:12:22,000
|
| 583 |
+
Like I said, my main concern is performance.
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:12:22,000 --> 00:12:28,000
|
| 587 |
+
Yes, using JDBC is not so fancy and it takes longer to write the code.
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:12:28,000 --> 00:12:30,000
|
| 591 |
+
But that's the way how I work.
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:12:31,000 --> 00:12:38,000
|
| 595 |
+
I also saw how Spring Data JPA is applied in production environment and I can confirm that it is also
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:12:38,000 --> 00:12:39,000
|
| 599 |
+
possible.
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:12:39,000 --> 00:12:47,000
|
| 603 |
+
But in my opinion, spring data JPA brings not so much things besides fancy way to define Daos by just
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:12:47,000 --> 00:12:52,000
|
| 607 |
+
creating interfaces and using non-optimized massive wrappers.
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:12:52,000 --> 00:13:00,000
|
| 611 |
+
But even despite all these advantages, just remember that spring data also has advantages, and this
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:13:00,000 --> 00:13:06,000
|
| 615 |
+
true professionals will have to understand what the spring data JPA is and be ready to apply gained
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:13:06,000 --> 00:13:09,000
|
| 619 |
+
knowledge on practice when it is needed.
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:13:09,000 --> 00:13:14,000
|
| 623 |
+
That's all what I wanted to share with you in this introductory lesson.
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:13:14,000 --> 00:13:17,000
|
| 627 |
+
Let's recap what we have learned today.
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:13:17,000 --> 00:13:20,000
|
| 631 |
+
Today we did an overview of spring data.
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:13:21,000 --> 00:13:24,000
|
| 635 |
+
We reviewed what spring data modules exists.
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:13:25,000 --> 00:13:28,000
|
| 639 |
+
Also, we learned what a spring data JPA is.
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:13:29,000 --> 00:13:31,000
|
| 643 |
+
I explained what repositories are.
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:13:32,000 --> 00:13:34,000
|
| 647 |
+
We discussed briefly repository pattern.
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:13:35,000 --> 00:13:41,000
|
| 651 |
+
And at the end of the lesson we learned advantages and disadvantages of the Spring Data JPA.
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:13:41,000 --> 00:13:43,000
|
| 655 |
+
That's it for today.
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:13:43,000 --> 00:13:45,000
|
| 659 |
+
Thanks a lot for your attention.
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:13:45,000 --> 00:13:48,000
|
| 663 |
+
Have a great day and see you in the next lesson.
|
| 664 |
+
|
86 - Spring Data/002 Source-code-of-examples-commit-with-changes-.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/e9e37fb6749af4c7ec493a54acea7cadbbafd612
|
86 - Spring Data/002 Spring Data JPA Practice_en.srt
ADDED
|
@@ -0,0 +1,996 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:05,000 --> 00:00:06,000
|
| 3 |
+
Hello Tim.
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:06,000 --> 00:00:11,000
|
| 7 |
+
We already hold an overview of spring data and spring data JPA.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:11,000 --> 00:00:18,000
|
| 11 |
+
We learned advantages and disadvantages and key concepts and now it is time for practice.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:18,000 --> 00:00:22,000
|
| 15 |
+
This lesson will be completely dedicated to the practical examples.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:22,000 --> 00:00:28,000
|
| 19 |
+
Today we are going to configure our spring application to work with Spring Data JPA.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:28,000 --> 00:00:35,000
|
| 23 |
+
We are going to define all the necessary beans, configure data, source, add all necessary dependencies
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:35,000 --> 00:00:37,000
|
| 27 |
+
and things like that.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:37,000 --> 00:00:43,000
|
| 31 |
+
During the video together we are going to create our first spring data JPA repository.
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:43,000 --> 00:00:48,000
|
| 35 |
+
I'm going to show you how to define methods in the repository.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:48,000 --> 00:00:55,000
|
| 39 |
+
I will show you how we can use GPG and Native SQL queries in our repository.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:56,000 --> 00:01:01,000
|
| 43 |
+
Also, we will learn naming convention for masses in other spring data.
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:01:01,000 --> 00:01:06,000
|
| 47 |
+
JPA can generate queries based on the method names in the interface of our repository.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:01:06,000 --> 00:01:13,000
|
| 51 |
+
We need to name masses according to the specific pattern and we will learn such keywords.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:01:13,000 --> 00:01:20,000
|
| 55 |
+
And during the live demo you are going to see end to end example to understand how spring data JPA repository
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:01:20,000 --> 00:01:24,000
|
| 59 |
+
can be integrated into your application.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:01:24,000 --> 00:01:26,000
|
| 63 |
+
Let's start our lesson.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:01:26,000 --> 00:01:32,000
|
| 67 |
+
Before we start our lesson, I want to highlight that it is important that you watch previous theoretical
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:01:32,000 --> 00:01:40,000
|
| 71 |
+
lessons because the key terms and concepts about spring data JPA were discussed in the previous video.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:01:40,000 --> 00:01:46,000
|
| 75 |
+
So as I promised, this lesson will be completely focused on the practical examples.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:01:47,000 --> 00:01:51,000
|
| 79 |
+
Let me jump to the practical code examples and screen sharing.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:01:52,000 --> 00:01:58,000
|
| 83 |
+
During the demo, I am going to use our spring training project that we used in our spring course from
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:01:58,000 --> 00:01:58,000
|
| 87 |
+
the beginning.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:01:59,000 --> 00:02:05,000
|
| 91 |
+
And as always, you will be able to find all source code examples in attachments to the video.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:02:05,000 --> 00:02:12,000
|
| 95 |
+
So the first thing that we need to do, let's add all required dependencies into our POM XML.
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:02:12,000 --> 00:02:16,000
|
| 99 |
+
Let me open pom XML and review what I have added.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:02:16,000 --> 00:02:21,000
|
| 103 |
+
The main dependency for our lesson is spring data JPA dependency.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:02:21,000 --> 00:02:26,000
|
| 107 |
+
You can check Maven repository and add latest available version from there.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:02:27,000 --> 00:02:35,000
|
| 111 |
+
Also additional dependencies that I have added is Jackson data bind few words about this dependency.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:02:36,000 --> 00:02:41,000
|
| 115 |
+
I added it in order to convert objects into JSON.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:02:41,000 --> 00:02:50,000
|
| 119 |
+
If you remember, JSON is a JavaScript object notation, very popular string format for data, serialization
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:02:50,000 --> 00:02:53,000
|
| 123 |
+
and passing objects as strings in the network.
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:02:54,000 --> 00:03:02,000
|
| 127 |
+
In our today's example, I am going to build a rest service that is going to return US user objects
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:03:02,000 --> 00:03:03,000
|
| 131 |
+
in the JSON format.
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:03:04,000 --> 00:03:07,000
|
| 135 |
+
Don't worry, we are going to learn rest.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:03:07,000 --> 00:03:09,000
|
| 139 |
+
Topic in the separate lesson.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:03:09,000 --> 00:03:17,000
|
| 143 |
+
There is nothing super complex in it and conversion into JSON is optional for this lesson and it is
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:03:17,000 --> 00:03:19,000
|
| 147 |
+
done just for demo purposes.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:03:19,000 --> 00:03:26,000
|
| 151 |
+
The next changes that I introduced in this example are changes in the web config file.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:03:26,000 --> 00:03:27,000
|
| 155 |
+
Our configuration.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:03:28,000 --> 00:03:30,000
|
| 159 |
+
Let me open web config class.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:03:31,000 --> 00:03:33,000
|
| 163 |
+
Let's start from the top here.
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:03:33,000 --> 00:03:36,000
|
| 167 |
+
I added few important annotations.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:03:36,000 --> 00:03:39,000
|
| 171 |
+
They are enable transaction management.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:03:39,000 --> 00:03:45,000
|
| 175 |
+
This annotation allows users to use transaction management in application.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:03:46,000 --> 00:03:51,000
|
| 179 |
+
Enables springs annotation driven transaction management capability.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:03:51,000 --> 00:03:54,000
|
| 183 |
+
Enable repositories.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:03:54,000 --> 00:04:01,000
|
| 187 |
+
This annotation indicates where the repositories classes are present and you can see that I specified
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:04:01,000 --> 00:04:06,000
|
| 191 |
+
full package name where my repositories will be stored.
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:04:06,000 --> 00:04:11,000
|
| 195 |
+
For the sake of the demo, we are going to implement only one repository today.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:04:12,000 --> 00:04:15,000
|
| 199 |
+
Properties Source with a database properties.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:04:15,000 --> 00:04:17,000
|
| 203 |
+
Let's review this file.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:04:17,000 --> 00:04:21,000
|
| 207 |
+
It is located in the SRC main resources.
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:04:21,000 --> 00:04:28,000
|
| 211 |
+
As you can see, there is a similar properties that we usually use for configuration of the data source
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:04:28,000 --> 00:04:37,000
|
| 215 |
+
because in spring data JPA we also need to configure data, source, driver name, URL, user password,
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:04:37,000 --> 00:04:43,000
|
| 219 |
+
dialect and also specified property to show SQL queries.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:04:43,000 --> 00:04:47,000
|
| 223 |
+
Later in the configuration we are going to use this properties.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:04:47,000 --> 00:04:53,000
|
| 227 |
+
It is just a rule of thumb to keep variable properties separately from the source code.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:04:53,000 --> 00:04:56,000
|
| 231 |
+
Let's get back to web.config file.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:04:56,000 --> 00:05:03,000
|
| 235 |
+
For the sake of the demo, I separated spring data JPA configuration with markers here.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:05:03,000 --> 00:05:10,000
|
| 239 |
+
Taking into account, we add new feature with each new lesson to our imaginary project.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:05:10,000 --> 00:05:18,000
|
| 243 |
+
You can find here source code from other examples, but I use such markers to separate configurations
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:05:18,000 --> 00:05:21,000
|
| 247 |
+
for different features that will learn.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:05:21,000 --> 00:05:25,000
|
| 251 |
+
The redundant code from previous lessons is just commanded.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:05:26,000 --> 00:05:31,000
|
| 255 |
+
For example, if you remember we configured spring security in the previous learning module.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:05:32,000 --> 00:05:39,000
|
| 259 |
+
I just commented that section in order to not deal with the security configuration in this lesson.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:05:39,000 --> 00:05:47,000
|
| 263 |
+
I also commanded configuration of the spring security filter in our application initializer, but feel
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:05:47,000 --> 00:05:50,000
|
| 267 |
+
free to uncomment it if you wish.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:05:50,000 --> 00:05:54,000
|
| 271 |
+
So here you can see constants.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:05:54,000 --> 00:06:00,000
|
| 275 |
+
These are properties names in order we could extract required properties values from the properties
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:06:00,000 --> 00:06:01,000
|
| 279 |
+
file.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:06:02,000 --> 00:06:06,000
|
| 283 |
+
The first thing that we need to do is to configure data source.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:06:06,000 --> 00:06:10,000
|
| 287 |
+
Here you can see that I use driver manager data source.
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:06:10,000 --> 00:06:19,000
|
| 291 |
+
I set URL username password driver class name using values from the properties file that we already
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:06:19,000 --> 00:06:20,000
|
| 295 |
+
reviewed.
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:06:20,000 --> 00:06:29,000
|
| 299 |
+
Data source beam is configured and also we already had lesson where we learned how to extract properties
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:06:29,000 --> 00:06:29,000
|
| 303 |
+
in spring.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:06:30,000 --> 00:06:37,000
|
| 307 |
+
We inject environment type and call get property name Passing the property name.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:06:37,000 --> 00:06:42,000
|
| 311 |
+
Then we need to configure local container entity manager factory bean.
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:06:43,000 --> 00:06:48,000
|
| 315 |
+
We need this been to control the entities in this been.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:06:48,000 --> 00:06:56,000
|
| 319 |
+
You must specify the persistence provider that is hibernate persistence provider in our case.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:06:56,000 --> 00:07:05,000
|
| 323 |
+
Also, as you can see, I set data source packages to scan and I pass package name where all my entities
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:07:05,000 --> 00:07:09,000
|
| 327 |
+
are stored and I set GPA properties.
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:07:09,000 --> 00:07:10,000
|
| 331 |
+
Let's review.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:07:10,000 --> 00:07:11,000
|
| 335 |
+
What are they?
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:07:12,000 --> 00:07:18,000
|
| 339 |
+
There is a separate method and you can see that I extract properties from the database.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:07:18,000 --> 00:07:20,000
|
| 343 |
+
Properties file that we configure it.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:07:21,000 --> 00:07:27,000
|
| 347 |
+
And the last but not the least, being that we are going to configure in this file is transaction manager.
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:07:27,000 --> 00:07:31,000
|
| 351 |
+
In our case it is GP transaction manager.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:07:31,000 --> 00:07:38,000
|
| 355 |
+
Note that without configuring transaction manager we can't use transactional annotation.
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:07:39,000 --> 00:07:42,000
|
| 359 |
+
Now let's review entities.
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:07:42,000 --> 00:07:48,000
|
| 363 |
+
We created our entities during the lesson from the spring Security module when we configured authentication
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:07:48,000 --> 00:07:54,000
|
| 367 |
+
with the users extracted from the database based on the roles and privileges.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:07:54,000 --> 00:07:57,000
|
| 371 |
+
So let me just make a brief overview.
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:07:57,000 --> 00:08:02,000
|
| 375 |
+
Basically, each user can have multiple roles assigned.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:08:02,000 --> 00:08:05,000
|
| 379 |
+
Each role can have multiple privileges.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:08:05,000 --> 00:08:09,000
|
| 383 |
+
To be honest, nothing is extraordinary here.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:08:10,000 --> 00:08:13,000
|
| 387 |
+
I use GP annotations to configure entities.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:08:14,000 --> 00:08:21,000
|
| 391 |
+
In case you want to learn more, feel free to check GP section in my course Java from zero to first
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:08:21,000 --> 00:08:22,000
|
| 395 |
+
job.
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:08:22,000 --> 00:08:28,000
|
| 399 |
+
Now we are ready to create our first repository in the Repositories package.
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:08:28,000 --> 00:08:35,000
|
| 403 |
+
I created sub package for spring data and here is user repository that I created.
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:08:36,000 --> 00:08:39,000
|
| 407 |
+
I extended from the craft repository.
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:08:39,000 --> 00:08:43,000
|
| 411 |
+
I believe it is important for you to know what a crowd repository is.
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:08:43,000 --> 00:08:46,000
|
| 415 |
+
Let me open its source code.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:08:47,000 --> 00:08:54,000
|
| 419 |
+
So this is an interface for generic CRUD operations on a repository for a specific type.
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:08:54,000 --> 00:08:57,000
|
| 423 |
+
You can see that this is parameterized type.
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:08:58,000 --> 00:09:05,000
|
| 427 |
+
The first type should be the type of the entity you want to work with, and the second type is a type
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:09:05,000 --> 00:09:05,000
|
| 431 |
+
of ID.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:09:06,000 --> 00:09:16,000
|
| 435 |
+
By extending CRUD repository by default, you can use methods like save save all find by ID exists by
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:09:16,000 --> 00:09:20,000
|
| 439 |
+
the and other methods that you can see on the screen.
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:09:21,000 --> 00:09:29,000
|
| 443 |
+
Basically there are sufficient to execute standard, create, read, update, delete operations and
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:09:29,000 --> 00:09:36,000
|
| 447 |
+
as we discussed in the previous lesson, in case we need some additional data operations, we can easily
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:09:36,000 --> 00:09:38,000
|
| 451 |
+
define new methods in our repository.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:09:39,000 --> 00:09:42,000
|
| 455 |
+
Let's get back to define few other methods.
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:09:43,000 --> 00:09:50,000
|
| 459 |
+
For example, let's define method that will return us a list of users with the same first name.
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:09:50,000 --> 00:10:00,000
|
| 463 |
+
We use spring data JPA predefined pattern find by and field name first name and parameter.
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:10:00,000 --> 00:10:01,000
|
| 467 |
+
First name.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:10:01,000 --> 00:10:02,000
|
| 471 |
+
That's it.
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:10:03,000 --> 00:10:05,000
|
| 475 |
+
That's literally everything.
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:10:05,000 --> 00:10:11,000
|
| 479 |
+
What we need to do to define the behavior of finding all users by the first name field.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:10:12,000 --> 00:10:19,000
|
| 483 |
+
But what are the prefixes I can use when I define method name in Spring data JPA Repository?
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:10:20,000 --> 00:10:23,000
|
| 487 |
+
What is the pardon and naming convention?
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:10:23,000 --> 00:10:29,000
|
| 491 |
+
That's a great question and there are really different options and combinations that you can use while
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:10:29,000 --> 00:10:31,000
|
| 495 |
+
naming your methods.
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:10:31,000 --> 00:10:39,000
|
| 499 |
+
Spring Data JPA developers have tried to take into account the majority of possible options that you
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:10:39,000 --> 00:10:40,000
|
| 503 |
+
might need.
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:10:40,000 --> 00:10:48,000
|
| 507 |
+
This is one of the most important feature of spring data JPA because it reduces a lot of boilerplate
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:10:48,000 --> 00:10:48,000
|
| 511 |
+
code.
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:10:49,000 --> 00:10:56,000
|
| 515 |
+
Also, the chances of errors are less because these spring methods are well tested by many projects
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:10:56,000 --> 00:10:58,000
|
| 519 |
+
already using them.
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:10:59,000 --> 00:11:06,000
|
| 523 |
+
I don't think that it would be useful me creating each of the possible variation because the main thing
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:11:06,000 --> 00:11:12,000
|
| 527 |
+
is that you understand operations, how to create method and how to call it.
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:11:13,000 --> 00:11:20,000
|
| 531 |
+
And now let me show you the slides with the list of words that you can use when naming method, and
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:11:20,000 --> 00:11:25,000
|
| 535 |
+
I will elaborate a little bit more on naming convention in Spring Data JPA.
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:11:26,000 --> 00:11:32,000
|
| 539 |
+
I gathered all the keywords that you can use when declaring new method in repository.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:11:33,000 --> 00:11:40,000
|
| 543 |
+
Also, each keyword has sample and shows how it will be transformed into the gql.
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:11:40,000 --> 00:11:48,000
|
| 547 |
+
You can see here's example of and or is equals between less than and other keywords.
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:11:48,000 --> 00:11:53,000
|
| 551 |
+
Please put the video on the post now and explore the slides.
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:11:53,000 --> 00:11:56,000
|
| 555 |
+
As you can see, there are multiple of them.
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:11:57,000 --> 00:12:01,000
|
| 559 |
+
Feel free to get back to these examples when it will be needed.
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:12:02,000 --> 00:12:08,000
|
| 563 |
+
Once you finished review, press play and continue with the next examples.
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:12:08,000 --> 00:12:14,000
|
| 567 |
+
In case we want a more control, we can specify customized query using gql.
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:12:14,000 --> 00:12:17,000
|
| 571 |
+
Take a look at this example.
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:12:17,000 --> 00:12:25,000
|
| 575 |
+
In case I want to retrieve users by the first name ignoring case, I can specify this query using lower
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:12:25,000 --> 00:12:31,000
|
| 579 |
+
function right on top of the method that I'm going to use a little bit later.
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:12:31,000 --> 00:12:34,000
|
| 583 |
+
I'm going to show you this method in action to.
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:12:35,000 --> 00:12:40,000
|
| 587 |
+
Also, if we need, we can use native SQL queries.
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:12:40,000 --> 00:12:42,000
|
| 591 |
+
The principle is the same.
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:12:42,000 --> 00:12:49,000
|
| 595 |
+
We use query annotation above the method and we specify native equals to true.
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:12:50,000 --> 00:12:51,000
|
| 599 |
+
Let's proceed now.
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:12:53,000 --> 00:12:57,000
|
| 603 |
+
To continue with creation of our imaginary business case.
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:12:57,000 --> 00:13:04,000
|
| 607 |
+
The next thing that we need to do is actually some service that is located in our business layer of
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:13:04,000 --> 00:13:08,000
|
| 611 |
+
application that is going to use our repository.
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:13:08,000 --> 00:13:15,000
|
| 615 |
+
For this, I created user service class and injected my user repository here.
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:13:15,000 --> 00:13:20,000
|
| 619 |
+
In our particular case, we just delegate calls to the repository.
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:13:21,000 --> 00:13:25,000
|
| 623 |
+
But theoretically, this is the place where you can implement your business.
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:13:25,000 --> 00:13:33,000
|
| 627 |
+
Logic, for example, is a make multiple requests with a repository to get the data that you need or
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:13:33,000 --> 00:13:35,000
|
| 631 |
+
to process the data received.
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:13:35,000 --> 00:13:40,000
|
| 635 |
+
In another way, it is up to you and your business logic.
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:13:41,000 --> 00:13:47,000
|
| 639 |
+
Transactional annotation indicates that the message will be executed in the transaction.
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:13:47,000 --> 00:13:54,000
|
| 643 |
+
Spring will take care of the transaction management and now we need to create controller class in order
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:13:54,000 --> 00:13:58,000
|
| 647 |
+
to interact with a business layer over the web.
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:13:58,000 --> 00:14:02,000
|
| 651 |
+
In our today's example, I'm going to implement Rest controller.
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:14:02,000 --> 00:14:09,000
|
| 655 |
+
Don't worry, we are going to cover rest, architecture, topic and topic of rest controllers in other
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:14:09,000 --> 00:14:10,000
|
| 659 |
+
lessons.
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:14:10,000 --> 00:14:17,000
|
| 663 |
+
But right now I'm going to make just short and brief overview to help you understand what is happening
|
| 664 |
+
|
| 665 |
+
167
|
| 666 |
+
00:14:17,000 --> 00:14:17,000
|
| 667 |
+
here.
|
| 668 |
+
|
| 669 |
+
168
|
| 670 |
+
00:14:18,000 --> 00:14:22,000
|
| 671 |
+
I used a rest controller annotation in simple words.
|
| 672 |
+
|
| 673 |
+
169
|
| 674 |
+
00:14:22,000 --> 00:14:29,000
|
| 675 |
+
Rest controller annotation is a combination of controller and response body annotation.
|
| 676 |
+
|
| 677 |
+
170
|
| 678 |
+
00:14:29,000 --> 00:14:36,000
|
| 679 |
+
You already know what a controller annotation is, and I believe I showed you a response body annotation
|
| 680 |
+
|
| 681 |
+
171
|
| 682 |
+
00:14:36,000 --> 00:14:37,000
|
| 683 |
+
once.
|
| 684 |
+
|
| 685 |
+
172
|
| 686 |
+
00:14:37,000 --> 00:14:41,000
|
| 687 |
+
But let me remind you was the response body annotation.
|
| 688 |
+
|
| 689 |
+
173
|
| 690 |
+
00:14:41,000 --> 00:14:49,000
|
| 691 |
+
Our view resolver is not triggered and we write the value that is returned from the method in controller
|
| 692 |
+
|
| 693 |
+
174
|
| 694 |
+
00:14:49,000 --> 00:14:54,000
|
| 695 |
+
directly into the response body of our response object.
|
| 696 |
+
|
| 697 |
+
175
|
| 698 |
+
00:14:54,000 --> 00:14:56,000
|
| 699 |
+
Why we need this?
|
| 700 |
+
|
| 701 |
+
176
|
| 702 |
+
00:14:56,000 --> 00:15:05,000
|
| 703 |
+
Very often we implement applications that talk not directly to the end user, but talk with other applications
|
| 704 |
+
|
| 705 |
+
177
|
| 706 |
+
00:15:05,000 --> 00:15:07,000
|
| 707 |
+
and just passing data.
|
| 708 |
+
|
| 709 |
+
178
|
| 710 |
+
00:15:07,000 --> 00:15:15,000
|
| 711 |
+
In this case, there is no need to implement view layer and present data on the nice looking web pages,
|
| 712 |
+
|
| 713 |
+
179
|
| 714 |
+
00:15:15,000 --> 00:15:23,000
|
| 715 |
+
or you can use other framework on the front end and you just need to supply data to its components.
|
| 716 |
+
|
| 717 |
+
180
|
| 718 |
+
00:15:23,000 --> 00:15:31,000
|
| 719 |
+
That's why we don't need to resolve separate view and we can just put the data into the response body.
|
| 720 |
+
|
| 721 |
+
181
|
| 722 |
+
00:15:31,000 --> 00:15:37,000
|
| 723 |
+
Anyway, the cases can be different and we are going to review them in other lessons too.
|
| 724 |
+
|
| 725 |
+
182
|
| 726 |
+
00:15:37,000 --> 00:15:45,000
|
| 727 |
+
In our today's lesson, I just didn't want to resolve views because we need just to make sure that our
|
| 728 |
+
|
| 729 |
+
183
|
| 730 |
+
00:15:45,000 --> 00:15:51,000
|
| 731 |
+
spring data JPA works well and to seize data that is actually returned.
|
| 732 |
+
|
| 733 |
+
184
|
| 734 |
+
00:15:51,000 --> 00:15:59,000
|
| 735 |
+
And this is exactly why we added Jackson dependency for data serialization from Java objects into JSON
|
| 736 |
+
|
| 737 |
+
185
|
| 738 |
+
00:15:59,000 --> 00:16:00,000
|
| 739 |
+
and vice versa.
|
| 740 |
+
|
| 741 |
+
186
|
| 742 |
+
00:16:01,000 --> 00:16:08,000
|
| 743 |
+
When I return some object and we tell Spring to write it into the response body how spring should handle
|
| 744 |
+
|
| 745 |
+
187
|
| 746 |
+
00:16:08,000 --> 00:16:16,000
|
| 747 |
+
this because we can't put Java object into the response body, but we can put string into the response
|
| 748 |
+
|
| 749 |
+
188
|
| 750 |
+
00:16:16,000 --> 00:16:17,000
|
| 751 |
+
body.
|
| 752 |
+
|
| 753 |
+
189
|
| 754 |
+
00:16:17,000 --> 00:16:25,000
|
| 755 |
+
So spring uses Jackson in order to serialize Java, object into the JSON and return it to the client.
|
| 756 |
+
|
| 757 |
+
190
|
| 758 |
+
00:16:25,000 --> 00:16:26,000
|
| 759 |
+
Is it clear?
|
| 760 |
+
|
| 761 |
+
191
|
| 762 |
+
00:16:27,000 --> 00:16:34,000
|
| 763 |
+
So I use rest controller annotation and here a lot of different methods to interact with our business
|
| 764 |
+
|
| 765 |
+
192
|
| 766 |
+
00:16:34,000 --> 00:16:35,000
|
| 767 |
+
layer.
|
| 768 |
+
|
| 769 |
+
193
|
| 770 |
+
00:16:35,000 --> 00:16:41,000
|
| 771 |
+
Our goal for today's demo is to them a message from our user repository.
|
| 772 |
+
|
| 773 |
+
194
|
| 774 |
+
00:16:42,000 --> 00:16:46,000
|
| 775 |
+
Let's review today how we work such methods.
|
| 776 |
+
|
| 777 |
+
195
|
| 778 |
+
00:16:46,000 --> 00:16:47,000
|
| 779 |
+
Get user by ID.
|
| 780 |
+
|
| 781 |
+
196
|
| 782 |
+
00:16:48,000 --> 00:16:56,000
|
| 783 |
+
We'll just pass ID of one saved user and we expect to get back json of user.
|
| 784 |
+
|
| 785 |
+
197
|
| 786 |
+
00:16:57,000 --> 00:16:59,000
|
| 787 |
+
Net users by first name.
|
| 788 |
+
|
| 789 |
+
198
|
| 790 |
+
00:16:59,000 --> 00:17:03,000
|
| 791 |
+
Will pass first name and we expect two users to be returned.
|
| 792 |
+
|
| 793 |
+
199
|
| 794 |
+
00:17:04,000 --> 00:17:07,000
|
| 795 |
+
Get user by first name case insensitive.
|
| 796 |
+
|
| 797 |
+
200
|
| 798 |
+
00:17:08,000 --> 00:17:15,000
|
| 799 |
+
The goal of this endpoint invocation is to prove that GPU queries work as expected.
|
| 800 |
+
|
| 801 |
+
201
|
| 802 |
+
00:17:16,000 --> 00:17:24,000
|
| 803 |
+
If you remember, for such behavior, we declared GPU query get users ordered by first name.
|
| 804 |
+
|
| 805 |
+
202
|
| 806 |
+
00:17:24,000 --> 00:17:30,000
|
| 807 |
+
We will check this endpoint too in order to prove that native queries work as expected.
|
| 808 |
+
|
| 809 |
+
203
|
| 810 |
+
00:17:30,000 --> 00:17:30,000
|
| 811 |
+
To.
|
| 812 |
+
|
| 813 |
+
204
|
| 814 |
+
00:17:31,000 --> 00:17:39,000
|
| 815 |
+
The rest of the masses can be checked via a special client like Postman because we need to send requests
|
| 816 |
+
|
| 817 |
+
205
|
| 818 |
+
00:17:39,000 --> 00:17:48,000
|
| 819 |
+
via post, delete, put HTTP methods, but don't pay too much attention to those methods so far.
|
| 820 |
+
|
| 821 |
+
206
|
| 822 |
+
00:17:48,000 --> 00:17:52,000
|
| 823 |
+
We are going to learn how they work in separate lesson.
|
| 824 |
+
|
| 825 |
+
207
|
| 826 |
+
00:17:53,000 --> 00:17:57,000
|
| 827 |
+
So I started Web server and deployed our application.
|
| 828 |
+
|
| 829 |
+
208
|
| 830 |
+
00:17:57,000 --> 00:18:03,000
|
| 831 |
+
Now it is time to send some queries to the web server and see what will be returned.
|
| 832 |
+
|
| 833 |
+
209
|
| 834 |
+
00:18:03,000 --> 00:18:10,000
|
| 835 |
+
We are going to start from extracting user by ID user slash seven.
|
| 836 |
+
|
| 837 |
+
210
|
| 838 |
+
00:18:11,000 --> 00:18:15,000
|
| 839 |
+
Seven is an ID of one of our users from the database.
|
| 840 |
+
|
| 841 |
+
211
|
| 842 |
+
00:18:15,000 --> 00:18:21,000
|
| 843 |
+
I just checked beforehand in the database and made requests.
|
| 844 |
+
|
| 845 |
+
212
|
| 846 |
+
00:18:21,000 --> 00:18:25,000
|
| 847 |
+
So we can see that JSON is returned.
|
| 848 |
+
|
| 849 |
+
213
|
| 850 |
+
00:18:25,000 --> 00:18:34,000
|
| 851 |
+
If you wish, you can use any JSON file that is available online to see how our Java object is transformed
|
| 852 |
+
|
| 853 |
+
214
|
| 854 |
+
00:18:34,000 --> 00:18:36,000
|
| 855 |
+
into the JSON string.
|
| 856 |
+
|
| 857 |
+
215
|
| 858 |
+
00:18:36,000 --> 00:18:40,000
|
| 859 |
+
By the way, this is a good way to learn JSON structure.
|
| 860 |
+
|
| 861 |
+
216
|
| 862 |
+
00:18:41,000 --> 00:18:42,000
|
| 863 |
+
This is pretty intuitive.
|
| 864 |
+
|
| 865 |
+
217
|
| 866 |
+
00:18:43,000 --> 00:18:51,000
|
| 867 |
+
You can see the name of the fields and field values ID first name, last name, email, password, etcetera.
|
| 868 |
+
|
| 869 |
+
218
|
| 870 |
+
00:18:51,000 --> 00:18:57,000
|
| 871 |
+
There is an array of roles and each role may have array of privileges.
|
| 872 |
+
|
| 873 |
+
219
|
| 874 |
+
00:18:57,000 --> 00:19:05,000
|
| 875 |
+
Anyway, we can see that our repository returned us the data that we expected because this user has
|
| 876 |
+
|
| 877 |
+
220
|
| 878 |
+
00:19:05,000 --> 00:19:06,000
|
| 879 |
+
ID seven.
|
| 880 |
+
|
| 881 |
+
221
|
| 882 |
+
00:19:07,000 --> 00:19:09,000
|
| 883 |
+
Let's check another endpoint.
|
| 884 |
+
|
| 885 |
+
222
|
| 886 |
+
00:19:10,000 --> 00:19:13,000
|
| 887 |
+
Users by first name slash admin.
|
| 888 |
+
|
| 889 |
+
223
|
| 890 |
+
00:19:14,000 --> 00:19:19,000
|
| 891 |
+
The next endpoint that we are going to check is getting users by first name.
|
| 892 |
+
|
| 893 |
+
224
|
| 894 |
+
00:19:19,000 --> 00:19:27,000
|
| 895 |
+
I use admin as a first name parameter and when I send request I receive two users in return because
|
| 896 |
+
|
| 897 |
+
225
|
| 898 |
+
00:19:27,000 --> 00:19:31,000
|
| 899 |
+
in my database there are two users with admin first name.
|
| 900 |
+
|
| 901 |
+
226
|
| 902 |
+
00:19:32,000 --> 00:19:35,000
|
| 903 |
+
Everything is simple and predictable.
|
| 904 |
+
|
| 905 |
+
227
|
| 906 |
+
00:19:35,000 --> 00:19:41,000
|
| 907 |
+
We implemented SQL query that returns US users ignoring case.
|
| 908 |
+
|
| 909 |
+
228
|
| 910 |
+
00:19:41,000 --> 00:19:43,000
|
| 911 |
+
Let's try that endpoint.
|
| 912 |
+
|
| 913 |
+
229
|
| 914 |
+
00:19:44,000 --> 00:19:52,000
|
| 915 |
+
Users by first name case insensitive slash admin starting from the lower case.
|
| 916 |
+
|
| 917 |
+
230
|
| 918 |
+
00:19:53,000 --> 00:20:01,000
|
| 919 |
+
And when I use case insensitive and point, I again see our two users with admin first name because
|
| 920 |
+
|
| 921 |
+
231
|
| 922 |
+
00:20:01,000 --> 00:20:05,000
|
| 923 |
+
in the SQL query we used lower function.
|
| 924 |
+
|
| 925 |
+
232
|
| 926 |
+
00:20:05,000 --> 00:20:14,000
|
| 927 |
+
Let's now check the last endpoint in our today's demo to make sure that native queries also work users
|
| 928 |
+
|
| 929 |
+
233
|
| 930 |
+
00:20:14,000 --> 00:20:15,000
|
| 931 |
+
ordered by first name.
|
| 932 |
+
|
| 933 |
+
234
|
| 934 |
+
00:20:16,000 --> 00:20:19,000
|
| 935 |
+
And you can see we have three users returned.
|
| 936 |
+
|
| 937 |
+
235
|
| 938 |
+
00:20:19,000 --> 00:20:27,000
|
| 939 |
+
The first two users with the first name admin and the third one is with test first name.
|
| 940 |
+
|
| 941 |
+
236
|
| 942 |
+
00:20:27,000 --> 00:20:35,000
|
| 943 |
+
That proves that ordering by first name works as expected, and that means that we can apply other native
|
| 944 |
+
|
| 945 |
+
237
|
| 946 |
+
00:20:35,000 --> 00:20:36,000
|
| 947 |
+
SQL queries.
|
| 948 |
+
|
| 949 |
+
238
|
| 950 |
+
00:20:37,000 --> 00:20:37,000
|
| 951 |
+
Super.
|
| 952 |
+
|
| 953 |
+
239
|
| 954 |
+
00:20:38,000 --> 00:20:41,000
|
| 955 |
+
That's all what I wanted to share with you in this lesson.
|
| 956 |
+
|
| 957 |
+
240
|
| 958 |
+
00:20:41,000 --> 00:20:45,000
|
| 959 |
+
Let's recap what we have learned in the video.
|
| 960 |
+
|
| 961 |
+
241
|
| 962 |
+
00:20:46,000 --> 00:20:49,000
|
| 963 |
+
In this video, we configure it Spring Data JPA.
|
| 964 |
+
|
| 965 |
+
242
|
| 966 |
+
00:20:49,000 --> 00:20:52,000
|
| 967 |
+
We created our GPA repository.
|
| 968 |
+
|
| 969 |
+
243
|
| 970 |
+
00:20:53,000 --> 00:20:58,000
|
| 971 |
+
I explained how we can work with a SQL queries in our GPA repositories.
|
| 972 |
+
|
| 973 |
+
244
|
| 974 |
+
00:20:59,000 --> 00:21:04,000
|
| 975 |
+
I showed how we can declare native SQL queries in our GPA repositories.
|
| 976 |
+
|
| 977 |
+
245
|
| 978 |
+
00:21:04,000 --> 00:21:13,000
|
| 979 |
+
We discussed naming convention and learned how to name methods in the GPA repository and also we reviewed
|
| 980 |
+
|
| 981 |
+
246
|
| 982 |
+
00:21:13,000 --> 00:21:19,000
|
| 983 |
+
live demo with a spring data JPA to understand how it works and to end.
|
| 984 |
+
|
| 985 |
+
247
|
| 986 |
+
00:21:20,000 --> 00:21:21,000
|
| 987 |
+
That's all for this lesson.
|
| 988 |
+
|
| 989 |
+
248
|
| 990 |
+
00:21:21,000 --> 00:21:23,000
|
| 991 |
+
Thanks a lot for your attention.
|
| 992 |
+
|
| 993 |
+
249
|
| 994 |
+
00:21:23,000 --> 00:21:27,000
|
| 995 |
+
Have a great day and see you in the next lesson.
|
| 996 |
+
|
86 - Spring Data/external-links.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
002 Source-code-of-examples-commit-with-changes-
|
| 3 |
+
https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/e9e37fb6749af4c7ec493a54acea7cadbbafd612
|
87 - ===== EXAM Spring Data JPA - Online Shop =====/001 EXAM Spring Data JPA - Online Shop.html
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
+
<title>EXAM Spring Data JPA - Online Shop</title>
|
| 7 |
+
|
| 8 |
+
<style>
|
| 9 |
+
* {
|
| 10 |
+
box-sizing: border-box;
|
| 11 |
+
margin: 0;
|
| 12 |
+
padding: 0;
|
| 13 |
+
}
|
| 14 |
+
body {
|
| 15 |
+
font-family: var(--font-stack-text);
|
| 16 |
+
font-weight: 400;
|
| 17 |
+
line-height: 1.4;
|
| 18 |
+
font-size: 1.6rem;
|
| 19 |
+
color: #2d2f31;
|
| 20 |
+
}
|
| 21 |
+
.container {
|
| 22 |
+
position: relative;
|
| 23 |
+
height: 100%;
|
| 24 |
+
overflow-y: auto;
|
| 25 |
+
}
|
| 26 |
+
.content {
|
| 27 |
+
padding: 3.2rem 4.8rem;
|
| 28 |
+
word-break: break-word;
|
| 29 |
+
max-width: 69.6rem;
|
| 30 |
+
margin: 0 auto;
|
| 31 |
+
}
|
| 32 |
+
.heading {
|
| 33 |
+
margin-bottom: 24px;
|
| 34 |
+
font-family: -apple-system, BlinkMacSystemFont, Roboto, "Segoe UI", Helvetica, Arial, sans-serif,
|
| 35 |
+
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
| 36 |
+
font-weight: 700;
|
| 37 |
+
line-height: 1.2;
|
| 38 |
+
letter-spacing: 0;
|
| 39 |
+
font-size: 32px;
|
| 40 |
+
max-width: 36em;
|
| 41 |
+
}
|
| 42 |
+
.article-asset-container {
|
| 43 |
+
padding: 2.4rem;
|
| 44 |
+
}
|
| 45 |
+
.article-asset-container p {
|
| 46 |
+
font-size: 19px;
|
| 47 |
+
}
|
| 48 |
+
code {
|
| 49 |
+
background-color: #fff;
|
| 50 |
+
border: 1px solid #d1d7dc;
|
| 51 |
+
color: #b4690e;
|
| 52 |
+
font-size: 80%;
|
| 53 |
+
padding: 0.2rem 0.4rem;
|
| 54 |
+
font-family: sfmono-regular, Consolas, liberation mono, Menlo, Courier, monospace;
|
| 55 |
+
}
|
| 56 |
+
p {
|
| 57 |
+
font-weight: 400;
|
| 58 |
+
}
|
| 59 |
+
</style>
|
| 60 |
+
</head>
|
| 61 |
+
<body>
|
| 62 |
+
<div class="container">
|
| 63 |
+
<div class="content">
|
| 64 |
+
<div class="heading">EXAM Spring Data JPA - Online Shop</div>
|
| 65 |
+
<div class="article-asset-container"><p>During the exam task you are going to take template of the multimodule project - online shop, and integrate Spring Data JPA into the persistence module of the application.</p><h4>Attachments:</h4><p>Exam Task - <a href="https://docs.google.com/document/d/16Gx8rIHynGErVA5iSfmV7xLJ7VHKmWwKsCKbDIu3g6A/edit?usp=sharing" rel="noopener noreferrer" target="_blank">https://docs.google.com/document/d/16Gx8rIHynGErVA5iSfmV7xLJ7VHKmWwKsCKbDIu3g6A/edit?usp=sharing</a></p></div>
|
| 66 |
+
</div>
|
| 67 |
+
</div>
|
| 68 |
+
</body>
|
| 69 |
+
</html>
|
88 - Spring JDBC/001 Spring JDBC Overview_en.srt
ADDED
|
@@ -0,0 +1,624 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:05,000 --> 00:00:06,000
|
| 3 |
+
Hello, team.
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:06,000 --> 00:00:13,000
|
| 7 |
+
Today we continue learning spring and in this lesson we are going to talk about spring JDBC.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:14,000 --> 00:00:20,000
|
| 11 |
+
We are going to start our lesson from remembering what JDBC is in general.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:20,000 --> 00:00:26,000
|
| 15 |
+
I'm bad that if you watch spring module of my course, you already know what JDBC is.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:26,000 --> 00:00:32,000
|
| 19 |
+
But we will just briefly remember after that we'll talk about why we should use spring JDBC.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:33,000 --> 00:00:38,000
|
| 23 |
+
What problems of JDBC API are solved with the spring JDBC.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:39,000 --> 00:00:40,000
|
| 27 |
+
I will explain.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:40,000 --> 00:00:45,000
|
| 31 |
+
What is the difference between spring JDBC and spring data JDBC.
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:46,000 --> 00:00:49,000
|
| 35 |
+
Then we'll review different spring JDBC classes.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:49,000 --> 00:00:59,000
|
| 39 |
+
Namely we are going to learn JDBC template named parameter jdbc template simple jdbc insert simple JDBC
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:59,000 --> 00:01:00,000
|
| 43 |
+
call.
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:01:00,000 --> 00:01:01,000
|
| 47 |
+
Let's start our lesson.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:01:02,000 --> 00:01:05,000
|
| 51 |
+
Let's start from overview of JDBC.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:01:05,000 --> 00:01:11,000
|
| 55 |
+
I believe that if you watch this course then you already have understanding of what JDBC is.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:01:11,000 --> 00:01:17,000
|
| 59 |
+
But for the sake of this lesson, let me just briefly remind you what the JDBC is.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:01:17,000 --> 00:01:21,000
|
| 63 |
+
JDBC stands for Java Database Connectivity.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:01:21,000 --> 00:01:27,000
|
| 67 |
+
JDBC is a Java API to connect and execute the query with the database.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:01:27,000 --> 00:01:30,000
|
| 71 |
+
It is a part of Java Standard Edition.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:01:30,000 --> 00:01:36,000
|
| 75 |
+
JDBC API uses JDBC drivers to connect with the database.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:01:36,000 --> 00:01:42,000
|
| 79 |
+
We can use JDBC API to access data stored in any relational database.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:01:42,000 --> 00:01:49,000
|
| 83 |
+
With the help of JDBC API, we can save, update, delete and fetch data from the database.
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:01:50,000 --> 00:01:53,000
|
| 87 |
+
If you want to learn more about Java JDBC.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:01:53,000 --> 00:02:00,000
|
| 91 |
+
Just to remind you that in my course Java from zero to first job I have separate section about JDBC.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:02:00,000 --> 00:02:08,000
|
| 95 |
+
So why we can't just use plane JDBC and why we should use spring JDBC instead?
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:02:08,000 --> 00:02:10,000
|
| 99 |
+
What are benefits?
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:02:10,000 --> 00:02:12,000
|
| 103 |
+
Let's try to figure it out.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:02:13,000 --> 00:02:20,000
|
| 107 |
+
First of all, I would like to highlight that spring JDBC is a powerful mechanism to connect to the
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:02:20,000 --> 00:02:23,000
|
| 111 |
+
database and execute SQL queries.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:02:23,000 --> 00:02:31,000
|
| 115 |
+
As you may already guess, it uses JDBC API under the hood and it helps us to deal with different problems
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:02:31,000 --> 00:02:32,000
|
| 119 |
+
of JDBC API.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:02:33,000 --> 00:02:36,000
|
| 123 |
+
What kind of problems?
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:02:36,000 --> 00:02:44,000
|
| 127 |
+
When we use JDBC, we need to write a lot of code before and after executing the query, such as creating
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:02:44,000 --> 00:02:48,000
|
| 131 |
+
connection statement, closing the result, set connection, etcetera.
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:02:48,000 --> 00:02:55,000
|
| 135 |
+
Even despite we can use try with resources block still, we need to remember about it and implement
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:02:55,000 --> 00:02:57,000
|
| 139 |
+
it carefully.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:02:57,000 --> 00:03:02,000
|
| 143 |
+
We need to perform exception handling code on the database logic.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:03:02,000 --> 00:03:04,000
|
| 147 |
+
We need to handle transactions.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:03:04,000 --> 00:03:11,000
|
| 151 |
+
You remember that with the JDBC, we can manage transactions by manually committing transactions when
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:03:11,000 --> 00:03:12,000
|
| 155 |
+
needed.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:03:12,000 --> 00:03:17,000
|
| 159 |
+
Repetition of all this code in different methods is a time consuming task.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:03:18,000 --> 00:03:24,000
|
| 163 |
+
If you follow my course and don't skip lessons, then you should know already that there is spring data
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:03:24,000 --> 00:03:26,000
|
| 167 |
+
JDBC sub project.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:03:26,000 --> 00:03:29,000
|
| 171 |
+
So is it the same as spring JDBC?
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:03:30,000 --> 00:03:32,000
|
| 175 |
+
No, it is not the same.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:03:32,000 --> 00:03:37,000
|
| 179 |
+
And if it is different then what is the difference?
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:03:37,000 --> 00:03:45,000
|
| 183 |
+
Spring JDBC project just provides all of the spring abstractions over the plain JDBC data source that
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:03:45,000 --> 00:03:47,000
|
| 187 |
+
you can use with the spring framework.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:03:47,000 --> 00:03:55,000
|
| 191 |
+
For example, Spring's data source, which nicely hook into spring's transaction management capabilities
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:03:55,000 --> 00:03:57,000
|
| 195 |
+
like transactional annotation.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:03:57,000 --> 00:04:05,000
|
| 199 |
+
Also, the JDBC template is part of this module which allows you to execute SQL statements and extract
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:04:05,000 --> 00:04:13,000
|
| 203 |
+
objects from the result sets without dealing with exception handling or details of properly closing
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:04:13,000 --> 00:04:17,000
|
| 207 |
+
statements, connections and things like that.
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:04:17,000 --> 00:04:25,000
|
| 211 |
+
Spring data JDBC, on the other hand, provides the spring data abstraction over spring JDBC.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:04:25,000 --> 00:04:35,000
|
| 215 |
+
That is, you can create a spring data crud repository and simple entity, not a GPA entity and a spring
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:04:35,000 --> 00:04:36,000
|
| 219 |
+
data does.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:04:36,000 --> 00:04:43,000
|
| 223 |
+
It will create your queries for you without you having to write native CRUD queries over JDBC.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:04:44,000 --> 00:04:51,000
|
| 227 |
+
Basically, this is the key difference between spring JDBC project and spring data.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:04:51,000 --> 00:04:55,000
|
| 231 |
+
JDBC sub project of Spring data project.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:04:55,000 --> 00:04:57,000
|
| 235 |
+
Hope you are not confused now.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:04:58,000 --> 00:05:04,000
|
| 239 |
+
Let's get back to the spring JDBC and discuss the main classes in the spring JDBC.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:05:05,000 --> 00:05:08,000
|
| 243 |
+
There are different ways how you can work with the spring JDBC.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:05:09,000 --> 00:05:19,000
|
| 247 |
+
I can name four main approaches with JDBC template named parameter jdbc template simple JDBC insert
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:05:19,000 --> 00:05:21,000
|
| 251 |
+
and simple JDBC call.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:05:22,000 --> 00:05:27,000
|
| 255 |
+
So basically you can use these classes to interact with the JDBC API.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:05:27,000 --> 00:05:31,000
|
| 259 |
+
During the practical examples, we are going to review how to work with them.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:05:31,000 --> 00:05:37,000
|
| 263 |
+
JDBC template is a classic spring JDBC approach and the most popular.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:05:37,000 --> 00:05:43,000
|
| 267 |
+
This is lowest level approach and all others use a JDBC template under the hood.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:05:44,000 --> 00:05:50,000
|
| 271 |
+
Pay attention to the part where I said that all others use a JDBC template.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:05:50,000 --> 00:05:51,000
|
| 275 |
+
Under the hood.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:05:51,000 --> 00:05:59,000
|
| 279 |
+
Let's make brief overview of different approaches and we will try to understand what are the differences
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:05:59,000 --> 00:06:02,000
|
| 283 |
+
between them and when to use what.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:06:03,000 --> 00:06:11,000
|
| 287 |
+
And we are going to start from review of the JDBC template class taking into account it is used under
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:06:11,000 --> 00:06:11,000
|
| 291 |
+
the hood.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:06:11,000 --> 00:06:21,000
|
| 295 |
+
Even in other classes, you can understand that it takes a central place among spring JDBC support classes.
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:06:21,000 --> 00:06:29,000
|
| 299 |
+
It takes care of creation and release of resources such as creating and closing of connection, object,
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:06:29,000 --> 00:06:29,000
|
| 303 |
+
etcetera.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:06:29,000 --> 00:06:33,000
|
| 307 |
+
So it will not lead to any problem.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:06:33,000 --> 00:06:41,000
|
| 311 |
+
If you forget to close the connection, it handles the exception and provides the informative exception
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:06:41,000 --> 00:06:48,000
|
| 315 |
+
messages with the help of exception classes defined in the work Spring Framework DAO package.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:06:49,000 --> 00:06:57,000
|
| 319 |
+
We can perform all the database operations with the help of JDBC template class such as insertion,
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:06:57,000 --> 00:07:06,000
|
| 323 |
+
update, deletion and retrieval of the data from the database instances of the template class are thread
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:07:06,000 --> 00:07:15,000
|
| 327 |
+
safe once configured so you can configure a single instance of a JDBC template and then safely inject
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:07:15,000 --> 00:07:18,000
|
| 331 |
+
this shared reference into multiple Daos.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:07:19,000 --> 00:07:26,000
|
| 335 |
+
A common practice when using the JDBC template class is to configure a data source in your spring configuration
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:07:26,000 --> 00:07:28,000
|
| 339 |
+
file and then dependency.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:07:28,000 --> 00:07:32,000
|
| 343 |
+
Inject that shared data source bean into your DAO classes.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:07:33,000 --> 00:07:42,000
|
| 347 |
+
Now let's review named parameter JDBC template and to understand it better, let's compare it with JDBC
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:07:42,000 --> 00:07:42,000
|
| 351 |
+
template.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:07:42,000 --> 00:07:50,000
|
| 355 |
+
When you use JDBC template, you give it SQL that has a question mark placeholder for each parameter
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:07:50,000 --> 00:07:52,000
|
| 359 |
+
you want to substitute in the SQL.
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:07:53,000 --> 00:08:01,000
|
| 363 |
+
When you assign parameters in the code, you have to pass input arguments in an array and they are used
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:08:01,000 --> 00:08:07,000
|
| 367 |
+
in the order in which they appear in the array like you can see on the slide.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:08:08,000 --> 00:08:11,000
|
| 371 |
+
You can see I created an array of arguments.
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:08:12,000 --> 00:08:22,000
|
| 375 |
+
I created SQL query with question marks, and then I pass SQL query array of arguments and result set
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:08:22,000 --> 00:08:23,000
|
| 379 |
+
extractor.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:08:24,000 --> 00:08:26,000
|
| 383 |
+
I'm going to explain you what it is.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:08:26,000 --> 00:08:30,000
|
| 387 |
+
Later during the practical coding exercise.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:08:31,000 --> 00:08:39,000
|
| 391 |
+
Named parameter JDBC template allows you to assign names to the parameter placeholders and pass in a
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:08:39,000 --> 00:08:44,000
|
| 395 |
+
map so the template can match the map names to the placeholders.
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:08:44,000 --> 00:08:54,000
|
| 399 |
+
So your code would look like other example on the slide we create again SQL query pay attention that
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:08:54,000 --> 00:08:59,000
|
| 403 |
+
we use named parameter my A and my B.
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:08:59,000 --> 00:09:10,000
|
| 407 |
+
After that I create map object and I put in the map keys and values and after that I call query method
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:09:10,000 --> 00:09:14,000
|
| 411 |
+
and pass SQL arguments and result set extractor.
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:09:14,000 --> 00:09:23,000
|
| 415 |
+
The idea is that matching the arguments by name is less error prone than having to specify them in a
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:09:23,000 --> 00:09:24,000
|
| 419 |
+
particular order.
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:09:25,000 --> 00:09:33,000
|
| 423 |
+
In real life applications, you store SQL queries in the separate files and it may be easy to accidentally
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:09:33,000 --> 00:09:36,000
|
| 427 |
+
put the parameters in the wrong order.
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:09:37,000 --> 00:09:39,000
|
| 431 |
+
Few words about simple jdbc.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:09:39,000 --> 00:09:40,000
|
| 435 |
+
Insert.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:09:41,000 --> 00:09:42,000
|
| 439 |
+
Simple JDBC.
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:09:42,000 --> 00:09:48,000
|
| 443 |
+
Insert optimized database metadata to limit the amount of necessary configuration.
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:09:48,000 --> 00:09:56,000
|
| 447 |
+
This approach simplifies coding so that you only need to provide the name of the table or procedure
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:09:56,000 --> 00:10:02,000
|
| 451 |
+
and provide a map of parameters matching the column names to help you understand it better.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:10:02,000 --> 00:10:05,000
|
| 455 |
+
Let's look on the example on the slide.
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:10:06,000 --> 00:10:12,000
|
| 459 |
+
If you need to make an insert with the JDBC template, you would have something like you can see on
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:10:12,000 --> 00:10:13,000
|
| 463 |
+
the slide.
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:10:14,000 --> 00:10:17,000
|
| 467 |
+
You would create JDBC template object.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:10:17,000 --> 00:10:19,000
|
| 471 |
+
SQL insert statement.
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:10:19,000 --> 00:10:25,000
|
| 475 |
+
And after that you would call update method on JDBC template passing parameters.
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:10:25,000 --> 00:10:33,000
|
| 479 |
+
In case we use simple JDBC insert clause, our code will look like on the example on the slide.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:10:33,000 --> 00:10:38,000
|
| 483 |
+
As you can see, I create instance of simple jdbc insert type.
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:10:38,000 --> 00:10:40,000
|
| 487 |
+
I specify concrete table.
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:10:40,000 --> 00:10:46,000
|
| 491 |
+
After that I create object of map type and they put values into it.
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:10:46,000 --> 00:10:51,000
|
| 495 |
+
The keys are column names in the table that we specified.
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:10:51,000 --> 00:10:56,000
|
| 499 |
+
The returned value is the number of rows affected by the query.
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:10:56,000 --> 00:11:04,000
|
| 503 |
+
As you can see with a simple JDBC insert, you don't have to write SQL, insert statement and using
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:11:04,000 --> 00:11:05,000
|
| 507 |
+
named parameters.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:11:05,000 --> 00:11:09,000
|
| 511 |
+
Same as the column names make the code more readable.
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:11:10,000 --> 00:11:13,000
|
| 515 |
+
Let's now talk about simple JDBC call.
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:11:14,000 --> 00:11:20,000
|
| 519 |
+
In simple words, this is a tool provided by spring JDBC to invoke stored procedures.
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:11:21,000 --> 00:11:26,000
|
| 523 |
+
If you don't remember what stored procedures are, please refer to my course Java from zero to first
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:11:26,000 --> 00:11:27,000
|
| 527 |
+
job.
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:11:27,000 --> 00:11:33,000
|
| 531 |
+
There is a section about SQL where I have separate lesson about stored procedures.
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:11:34,000 --> 00:11:42,000
|
| 535 |
+
A simple JDBC call is a multi-threaded reusable object representing a call to a stored procedure or
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:11:42,000 --> 00:11:43,000
|
| 539 |
+
a stored function.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:11:43,000 --> 00:11:51,000
|
| 543 |
+
It provides metadata processing to simplify the code needed to access basic stored procedures functions.
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:11:51,000 --> 00:11:58,000
|
| 547 |
+
All you need to provide is the name of the procedure or function and the map containing the parameters
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:11:58,000 --> 00:12:00,000
|
| 551 |
+
when you execute the call.
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:12:01,000 --> 00:12:08,000
|
| 555 |
+
The names of the supplied parameters will be matched up within and out parameters declared when the
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:12:08,000 --> 00:12:10,000
|
| 559 |
+
stored procedure was created.
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:12:11,000 --> 00:12:13,000
|
| 563 |
+
Let's look at the example on the slide.
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:12:13,000 --> 00:12:16,000
|
| 567 |
+
Create object of simple JDBC call.
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:12:17,000 --> 00:12:22,000
|
| 571 |
+
Then I can specify in parameters if required by the procedure.
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:12:23,000 --> 00:12:31,000
|
| 575 |
+
Then we can execute the procedure and get the values of the out parameters into map and then we can
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:12:31,000 --> 00:12:34,000
|
| 579 |
+
read out the values returned from the procedure.
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:12:35,000 --> 00:12:43,000
|
| 583 |
+
Note the names of in and out parameters must match the names declared by the stored procedure of function.
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:12:44,000 --> 00:12:48,000
|
| 587 |
+
Basically, that's all what I wanted to share with you in this video.
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:12:48,000 --> 00:12:55,000
|
| 591 |
+
In the next lesson, we are going to have practical examples and full lesson of coding exercises.
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:12:55,000 --> 00:12:59,000
|
| 595 |
+
And right now, let's recap what we have learned in the video.
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:13:00,000 --> 00:13:03,000
|
| 599 |
+
Today we learned what a spring JDBC is.
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:13:03,000 --> 00:13:10,000
|
| 603 |
+
I explained what problems of JDBC API can be easily solved with a spring JDBC.
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:13:11,000 --> 00:13:19,000
|
| 607 |
+
After this lesson, we understand the difference between spring JDBC and spring data JDBC projects.
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:13:19,000 --> 00:13:28,000
|
| 611 |
+
We learned different classes from spring JDBC, namely JDBC template named parameter JDBC template simple
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:13:28,000 --> 00:13:32,000
|
| 615 |
+
JDBC insert simple JDBC call.
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:13:33,000 --> 00:13:34,000
|
| 619 |
+
Thanks a lot for your attention.
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:13:34,000 --> 00:13:37,000
|
| 623 |
+
Have a great day and see you in the next lesson.
|
| 624 |
+
|
88 - Spring JDBC/002 Source-code-of-examples-commit-with-changes-.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/914fe50d4a0da192c913cd2d91560f3a03d60fa1
|
88 - Spring JDBC/002 Spring JDBC Practice_en.srt
ADDED
|
@@ -0,0 +1,1396 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
3
|
| 10 |
+
00:00:09,000 --> 00:00:13,000
|
| 11 |
+
And today we continue learning Spring JDBC.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:14,000 --> 00:00:20,000
|
| 15 |
+
We're going to start this lesson from the overview of the main packages in the Spring JDBC Library.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:20,000 --> 00:00:28,000
|
| 19 |
+
This is supposed to help you to navigate in the documentation and understand how classes are grouped
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:28,000 --> 00:00:29,000
|
| 23 |
+
in the library.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:30,000 --> 00:00:33,000
|
| 27 |
+
After that, we will jump to practical code examples.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:33,000 --> 00:00:37,000
|
| 31 |
+
We'll configure the dependencies needed in our PWM XML.
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:37,000 --> 00:00:44,000
|
| 35 |
+
For all practical examples, we are going to configure all required beans and then I'm going to show
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:44,000 --> 00:00:48,000
|
| 39 |
+
you in action how to work with key classes from Spring JDBC.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:49,000 --> 00:00:56,000
|
| 43 |
+
Namely, we are going to have examples with JDBC template named parameter JDBC template simple jdbc
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:56,000 --> 00:00:59,000
|
| 47 |
+
insert simple JDBC call.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:01:00,000 --> 00:01:07,000
|
| 51 |
+
I'm going to show you how to do batch updates and what parameter source utils class is.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:01:07,000 --> 00:01:15,000
|
| 55 |
+
Also, during the lesson, I'm going to explain you what row mapper is, how and when to use it.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:01:15,000 --> 00:01:17,000
|
| 59 |
+
Let's start our lesson.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:01:18,000 --> 00:01:21,000
|
| 63 |
+
And as I said before, we jump to practical code examples.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:01:21,000 --> 00:01:28,000
|
| 67 |
+
Let me just make a brief overview of packages in Spring JDBC library in order you could understand the
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:01:28,000 --> 00:01:35,000
|
| 71 |
+
logic of grouping classes and in order to help you to navigate in the documentation in case you would
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:01:35,000 --> 00:01:37,000
|
| 75 |
+
like to find something.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:01:37,000 --> 00:01:43,000
|
| 79 |
+
So all classes in spring JDBC are grouped into four separate packages.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:01:43,000 --> 00:01:50,000
|
| 83 |
+
They are core in this package located the core functionality of JDBC.
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:01:50,000 --> 00:01:55,000
|
| 87 |
+
There are a few sub packages like metadata named Param.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:01:55,000 --> 00:01:57,000
|
| 91 |
+
Simple support.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:01:58,000 --> 00:02:06,000
|
| 95 |
+
Some of the important classes under this package include JDBC template simple JDBC insert simple JDBC
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:02:06,000 --> 00:02:10,000
|
| 99 |
+
call and named parameter JDBC template.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:02:10,000 --> 00:02:16,000
|
| 103 |
+
In the previous lesson we made a review of these classes, so make sure you watch the previous lesson
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:02:17,000 --> 00:02:18,000
|
| 107 |
+
config.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:02:18,000 --> 00:02:23,000
|
| 111 |
+
This package defines the spring JDBC configuration namespace.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:02:23,000 --> 00:02:32,000
|
| 115 |
+
It contains such classes as JDBC namespace handler and sorted resources Factory Bin data source.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:02:32,000 --> 00:02:37,000
|
| 119 |
+
In this package, you can find utility classes to access a data source.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:02:37,000 --> 00:02:44,000
|
| 123 |
+
It also has various data source implementation for testing JDBC code outside of the Jakarta Enterprise
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:02:44,000 --> 00:02:46,000
|
| 127 |
+
Edition container.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:02:47,000 --> 00:02:47,000
|
| 131 |
+
Object.
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:02:48,000 --> 00:02:53,000
|
| 135 |
+
The classes in this package represent relational database management system queries.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:02:53,000 --> 00:02:58,000
|
| 139 |
+
Updates and stored procedures as thread safe reusable objects.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:02:58,000 --> 00:03:03,000
|
| 143 |
+
It is also about database access in an object oriented manner.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:03:03,000 --> 00:03:07,000
|
| 147 |
+
It allows running queries and returns the results as a business object.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:03:07,000 --> 00:03:13,000
|
| 151 |
+
It also maps the query results between the columns and properties of business objects.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:03:14,000 --> 00:03:15,000
|
| 155 |
+
Support.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:03:15,000 --> 00:03:22,000
|
| 159 |
+
This package contains support classes for classes on the core and object packages.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:03:22,000 --> 00:03:27,000
|
| 163 |
+
For example, it provides a SQL exception translation functionality.
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:03:27,000 --> 00:03:28,000
|
| 167 |
+
That's it.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:03:29,000 --> 00:03:35,000
|
| 171 |
+
As I promised you at the beginning of the lesson today, we are going to have a lot of practical examples.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:03:35,000 --> 00:03:40,000
|
| 175 |
+
So let me start with the screen sharing and jump to the coding exercises.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:03:40,000 --> 00:03:44,000
|
| 179 |
+
All source code examples you can find in attachments to the video.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:03:45,000 --> 00:03:48,000
|
| 183 |
+
Just use the link attached to the video.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:03:48,000 --> 00:03:54,000
|
| 187 |
+
You can clone repository if you wish and try the source code on your computer.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:03:55,000 --> 00:04:00,000
|
| 191 |
+
We're going to start with adding dependency into our pom.xml.
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:04:00,000 --> 00:04:04,000
|
| 195 |
+
We just need to add spring JDBC dependency and that's it.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:04:04,000 --> 00:04:09,000
|
| 199 |
+
In my case I use the same version as for other spring dependencies.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:04:09,000 --> 00:04:15,000
|
| 203 |
+
You are welcome to check Maven repository and to select the version that you need.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:04:16,000 --> 00:04:22,000
|
| 207 |
+
Also, if you follow the course attentively, then you remember that in previous lessons we added all
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:04:22,000 --> 00:04:25,000
|
| 211 |
+
the Jackson data bind dependency.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:04:25,000 --> 00:04:30,000
|
| 215 |
+
It is needed in order to convert objects into the JSON and vice versa.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:04:30,000 --> 00:04:36,000
|
| 219 |
+
Spring internally is going to use this dependency when we will use response body.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:04:36,000 --> 00:04:37,000
|
| 223 |
+
Let's move on.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:04:38,000 --> 00:04:41,000
|
| 227 |
+
Now let's configure all necessary bins.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:04:42,000 --> 00:04:44,000
|
| 231 |
+
I open Web.config class.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:04:44,000 --> 00:04:48,000
|
| 235 |
+
We need to make sure that our data source bin is configured.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:04:48,000 --> 00:04:54,000
|
| 239 |
+
We configure it it already in our previous lessons when we learned spring data JPA.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:04:54,000 --> 00:04:55,000
|
| 243 |
+
Here it is.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:04:56,000 --> 00:05:01,000
|
| 247 |
+
Also, pay attention that it takes values from the property resource.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:05:01,000 --> 00:05:07,000
|
| 251 |
+
Just to remind you that here on top we also declared property source with the database properties.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:05:07,000 --> 00:05:12,000
|
| 255 |
+
Database Properties file is located in our resources folder.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:05:12,000 --> 00:05:19,000
|
| 259 |
+
I'm going to use the same properties because nothing is changed in our database configurations.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:05:19,000 --> 00:05:24,000
|
| 263 |
+
I mean JDBC driver username and password.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:05:24,000 --> 00:05:30,000
|
| 267 |
+
Also, there is an interesting question about whether you need to create multiple JDBC template instances
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:05:30,000 --> 00:05:37,000
|
| 271 |
+
or no, or just to create one instance and inject it in each DAO implementation.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:05:38,000 --> 00:05:43,000
|
| 275 |
+
Let's answer this question based on the example of the JDBC template.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:05:43,000 --> 00:05:51,000
|
| 279 |
+
JDBC template is thread safe, lock free, meaning it should not cause performance degradation when
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:05:51,000 --> 00:05:53,000
|
| 283 |
+
shared between concurrent threads.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:05:53,000 --> 00:06:00,000
|
| 287 |
+
Thus, there are no compelling reasons for more than one instance per data source.
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:06:00,000 --> 00:06:05,000
|
| 291 |
+
There is no problem to inject JDBC template to your multiple DAO.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:06:05,000 --> 00:06:14,000
|
| 295 |
+
The template is used to wire your data to the physical resource database connection when you need to
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:06:14,000 --> 00:06:15,000
|
| 299 |
+
run database query.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:06:16,000 --> 00:06:22,000
|
| 303 |
+
Spring manages the life cycle of the beans you need for working with your persistence layer.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:06:22,000 --> 00:06:25,000
|
| 307 |
+
The advantages of using a template are.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:06:25,000 --> 00:06:32,000
|
| 311 |
+
JDBC template manages physical resources required to interact with the database automatically.
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:06:32,000 --> 00:06:37,000
|
| 315 |
+
By saying this, I mean create and release the database connections.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:06:37,000 --> 00:06:44,000
|
| 319 |
+
The spring JDBC template converts the standard JDBC SQL exceptions into runtime exceptions.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:06:44,000 --> 00:06:48,000
|
| 323 |
+
This allows you to react more flexible to the errors.
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:06:49,000 --> 00:06:56,000
|
| 327 |
+
The spring JDBC template converts also the vendor specific error messages into better understandable
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:06:56,000 --> 00:06:57,000
|
| 331 |
+
error messages.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:06:58,000 --> 00:07:02,000
|
| 335 |
+
So I created bin of the JDBC template here.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:07:02,000 --> 00:07:07,000
|
| 339 |
+
Pay attention that I inject data source into this class.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:07:08,000 --> 00:07:12,000
|
| 343 |
+
I created such been as named parameter jdbc template.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:07:12,000 --> 00:07:15,000
|
| 347 |
+
Also using data source been.
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:07:15,000 --> 00:07:19,000
|
| 351 |
+
The next files that I would like to review with you is user Dao.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:07:20,000 --> 00:07:26,000
|
| 355 |
+
If you want to refresh your knowledge about Dao pattern, please refer to my course Java from zero to
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:07:26,000 --> 00:07:26,000
|
| 359 |
+
first job.
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:07:27,000 --> 00:07:32,000
|
| 363 |
+
There you can find separate lesson about data access object design pattern.
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:07:32,000 --> 00:07:39,000
|
| 367 |
+
So our user DAO class will be in charge of the interaction with the relational database.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:07:39,000 --> 00:07:47,000
|
| 371 |
+
Basically, this is a class where we will use objects created based on the spring JDBC libraries classes
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:07:47,000 --> 00:07:50,000
|
| 375 |
+
in order to build and execute queries.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:07:50,000 --> 00:07:52,000
|
| 379 |
+
Let's look through it.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:07:53,000 --> 00:08:00,000
|
| 383 |
+
I injected JDBC template named parameter JDBC template and data source beans for the sake of examples
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:08:00,000 --> 00:08:03,000
|
| 387 |
+
that I described in this file.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:08:03,000 --> 00:08:05,000
|
| 391 |
+
Let's review the first simple example.
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:08:05,000 --> 00:08:13,000
|
| 395 |
+
Just simple select statement that returns us integer total count of users in the database.
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:08:14,000 --> 00:08:22,000
|
| 399 |
+
I use method query for object of JDBC template object and pass the SQL query and class to which I want
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:08:22,000 --> 00:08:24,000
|
| 403 |
+
to cast the result.
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:08:24,000 --> 00:08:32,000
|
| 407 |
+
As you can see, I want to extract total count of users present in the database in the table user.
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:08:33,000 --> 00:08:36,000
|
| 411 |
+
Obviously the result will be integer number.
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:08:36,000 --> 00:08:39,000
|
| 415 |
+
That's why class for casting is integer.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:08:40,000 --> 00:08:46,000
|
| 419 |
+
Just to note, I believe that you understand that SQL queries can be stored in different files.
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:08:46,000 --> 00:08:54,000
|
| 423 |
+
For example, you can store SQL queries in properties files and fetch them when needed.
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:08:54,000 --> 00:09:00,000
|
| 427 |
+
In this lesson, I decided to keep SQL queries as part of the source code for demo purposes in order
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:09:00,000 --> 00:09:08,000
|
| 431 |
+
to not switch screens very fast and do not navigate between multiple files a lot of times.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:09:08,000 --> 00:09:12,000
|
| 435 |
+
So just look at this first simple example.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:09:13,000 --> 00:09:19,000
|
| 439 |
+
I just injected JDBC template and just call methods that I need with a SQL query.
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:09:19,000 --> 00:09:20,000
|
| 443 |
+
That's it.
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:09:20,000 --> 00:09:24,000
|
| 447 |
+
No more creating Connection Creating Statement Objects.
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:09:24,000 --> 00:09:26,000
|
| 451 |
+
Closing Connection.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:09:26,000 --> 00:09:27,000
|
| 455 |
+
Closing Statements.
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:09:27,000 --> 00:09:30,000
|
| 459 |
+
Extracting ResultSet Closing Result Set.
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:09:30,000 --> 00:09:34,000
|
| 463 |
+
Can you see how simple code looks like?
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:09:34,000 --> 00:09:41,000
|
| 467 |
+
That's one of the biggest advantages of spring simplification and removing of boilerplate code.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:09:42,000 --> 00:09:47,000
|
| 471 |
+
Basically, I have nothing more to add here with regards to this first example.
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:09:48,000 --> 00:09:54,000
|
| 475 |
+
Integer will be returned and I'm going to demo how this code works at the end of the lesson.
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:09:55,000 --> 00:09:56,000
|
| 479 |
+
Let's continue.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:09:57,000 --> 00:10:00,000
|
| 483 |
+
Let's review simple insert statement.
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:10:00,000 --> 00:10:03,000
|
| 487 |
+
Here you can see method at sample user.
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:10:03,000 --> 00:10:09,000
|
| 491 |
+
This is how you can execute insert statement with the JDBC template object.
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:10:10,000 --> 00:10:17,000
|
| 495 |
+
Pay attention that I use question marks for SQL query parameters instead of string concatenation in
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:10:17,000 --> 00:10:19,000
|
| 499 |
+
order to avoid SQL injection.
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:10:19,000 --> 00:10:27,000
|
| 503 |
+
After the SQL statement, I pass parameters that should be injected into the SQL statement similar to
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:10:27,000 --> 00:10:29,000
|
| 507 |
+
the prepared statement from the JDBC.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:10:29,000 --> 00:10:31,000
|
| 511 |
+
If you remember.
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:10:31,000 --> 00:10:38,000
|
| 515 |
+
Of course, all these parameters should go from the outside and should be passed to the method.
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:10:38,000 --> 00:10:46,000
|
| 519 |
+
But in order to not complicate example and put all focus on the spring JDBC, I decided to hardcode
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:10:46,000 --> 00:10:47,000
|
| 523 |
+
some values here.
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:10:48,000 --> 00:10:53,000
|
| 527 |
+
Now let's review how we can work with the named parameter JDBC template.
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:10:54,000 --> 00:11:01,000
|
| 531 |
+
I believe that from previous theoretical lessons you already know the purpose of this type.
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:11:01,000 --> 00:11:08,000
|
| 535 |
+
But just to remind you, we are going to use a special template in order to use named parameters instead
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:11:08,000 --> 00:11:09,000
|
| 539 |
+
of question marks.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:11:09,000 --> 00:11:17,000
|
| 543 |
+
This makes sense because in general it is considered that risk of making mistake was named parameters
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:11:17,000 --> 00:11:18,000
|
| 547 |
+
is less.
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:11:18,000 --> 00:11:26,000
|
| 551 |
+
Imagine in case your SQL queries are stored in another file and you need to pass parameters in a strict
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:11:26,000 --> 00:11:32,000
|
| 555 |
+
sequence and you need to make sure that you passed all parameters correctly.
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:11:32,000 --> 00:11:40,000
|
| 559 |
+
Or let's imagine that somebody adjusted SQL statement and you have wrong sequence of arguments right
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:11:40,000 --> 00:11:42,000
|
| 563 |
+
now configured in the source code.
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:11:43,000 --> 00:11:50,000
|
| 567 |
+
Anyway, haven't parameter name and associated value will give you better visibility and control over
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:11:50,000 --> 00:11:53,000
|
| 571 |
+
building the and SQL query.
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:11:54,000 --> 00:11:55,000
|
| 575 |
+
Under the hood.
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:11:55,000 --> 00:12:03,000
|
| 579 |
+
It substitutes the named parameters to jdbc question mark placeholder and delegates to the wrapped JDBC
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:12:03,000 --> 00:12:06,000
|
| 583 |
+
template to run the queries.
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:12:06,000 --> 00:12:15,000
|
| 587 |
+
So here is the method that is called get last name of user by id where I use named parameter JDBC template.
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:12:15,000 --> 00:12:19,000
|
| 591 |
+
I declare a variable of the SQL parameter source type.
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:12:20,000 --> 00:12:29,000
|
| 595 |
+
This interface is intended to wrap various implementations like a map or a Java bean with a consistent
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:12:29,000 --> 00:12:30,000
|
| 599 |
+
interface.
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:12:30,000 --> 00:12:34,000
|
| 603 |
+
I create object of map parameter source.
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:12:34,000 --> 00:12:42,000
|
| 607 |
+
Basically, this is implementation of SQL parameter source that holds a given map of parameters into
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:12:42,000 --> 00:12:43,000
|
| 611 |
+
the map.
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:12:43,000 --> 00:12:47,000
|
| 615 |
+
I added parameter with value passed as method argument.
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:12:48,000 --> 00:12:53,000
|
| 619 |
+
After that I pass SQL query to the query for object method.
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:12:53,000 --> 00:12:56,000
|
| 623 |
+
Pay attention how I use named parameter.
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:12:57,000 --> 00:13:05,000
|
| 627 |
+
Here's a ye named parameter and I pass my map in order to inject parameter values into the SQL query.
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:13:05,000 --> 00:13:08,000
|
| 631 |
+
Basically that's how it works.
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:13:08,000 --> 00:13:16,000
|
| 635 |
+
But you can use not only map of parameters, you can also use bean for mapping parameters.
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:13:16,000 --> 00:13:18,000
|
| 639 |
+
Let me show you how.
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:13:18,000 --> 00:13:20,000
|
| 643 |
+
Below you can see similar method.
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:13:20,000 --> 00:13:22,000
|
| 647 |
+
There are few differences.
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:13:22,000 --> 00:13:32,000
|
| 651 |
+
Instead of passing just integer id, I pass user object and instead of creation map SQL parameter source
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:13:32,000 --> 00:13:34,000
|
| 655 |
+
or object, I create bean property.
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:13:35,000 --> 00:13:40,000
|
| 659 |
+
SQL Parameter Source object and pass my user object into the constructor.
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:13:40,000 --> 00:13:47,000
|
| 663 |
+
This object obtains parameter values from bean properties of a given Java bean object.
|
| 664 |
+
|
| 665 |
+
167
|
| 666 |
+
00:13:47,000 --> 00:13:53,000
|
| 667 |
+
The names of the bean properties have to match the parameter names.
|
| 668 |
+
|
| 669 |
+
168
|
| 670 |
+
00:13:53,000 --> 00:13:55,000
|
| 671 |
+
The rest is the same.
|
| 672 |
+
|
| 673 |
+
169
|
| 674 |
+
00:13:56,000 --> 00:14:00,000
|
| 675 |
+
I pass named parameters to the query for object method.
|
| 676 |
+
|
| 677 |
+
170
|
| 678 |
+
00:14:01,000 --> 00:14:04,000
|
| 679 |
+
Also here you can see example of batch update.
|
| 680 |
+
|
| 681 |
+
171
|
| 682 |
+
00:14:05,000 --> 00:14:12,000
|
| 683 |
+
In this particular example, I update our database by executing multiple insert statements and inserting
|
| 684 |
+
|
| 685 |
+
172
|
| 686 |
+
00:14:12,000 --> 00:14:13,000
|
| 687 |
+
users.
|
| 688 |
+
|
| 689 |
+
173
|
| 690 |
+
00:14:13,000 --> 00:14:22,000
|
| 691 |
+
I bet you remember that in JDBC we also can make batch updates and I showed you examples if you remember.
|
| 692 |
+
|
| 693 |
+
174
|
| 694 |
+
00:14:22,000 --> 00:14:30,000
|
| 695 |
+
So this is needed in order to optimize amount of queries sent to the database from our application in
|
| 696 |
+
|
| 697 |
+
175
|
| 698 |
+
00:14:30,000 --> 00:14:39,000
|
| 699 |
+
case we send batch request, all requests are sent at once and executed in one cycle in database, and
|
| 700 |
+
|
| 701 |
+
176
|
| 702 |
+
00:14:39,000 --> 00:14:42,000
|
| 703 |
+
this gives us additional optimization.
|
| 704 |
+
|
| 705 |
+
177
|
| 706 |
+
00:14:43,000 --> 00:14:49,000
|
| 707 |
+
This is helpful when you want to update multiple records in one table.
|
| 708 |
+
|
| 709 |
+
178
|
| 710 |
+
00:14:50,000 --> 00:14:53,000
|
| 711 |
+
I use class that is called SQL parameter source utils.
|
| 712 |
+
|
| 713 |
+
179
|
| 714 |
+
00:14:53,000 --> 00:14:59,000
|
| 715 |
+
It helps me to create batch source based on the array of my objects.
|
| 716 |
+
|
| 717 |
+
180
|
| 718 |
+
00:14:59,000 --> 00:15:05,000
|
| 719 |
+
And after that, having the SQL query, I can just pass the batch for execution.
|
| 720 |
+
|
| 721 |
+
181
|
| 722 |
+
00:15:06,000 --> 00:15:13,000
|
| 723 |
+
Another super interesting and useful feature of spring JDBC is possibility to map query results to Java
|
| 724 |
+
|
| 725 |
+
182
|
| 726 |
+
00:15:13,000 --> 00:15:17,000
|
| 727 |
+
objects by implementing row mapper interface.
|
| 728 |
+
|
| 729 |
+
183
|
| 730 |
+
00:15:18,000 --> 00:15:24,000
|
| 731 |
+
In the simple JDBC, I believe you remember that you had to work with a result set and extract values
|
| 732 |
+
|
| 733 |
+
184
|
| 734 |
+
00:15:24,000 --> 00:15:26,000
|
| 735 |
+
from the result set.
|
| 736 |
+
|
| 737 |
+
185
|
| 738 |
+
00:15:26,000 --> 00:15:35,000
|
| 739 |
+
Actually there is a way how to create reusable code even in JDBC, but in spring JDBC it is implemented
|
| 740 |
+
|
| 741 |
+
186
|
| 742 |
+
00:15:35,000 --> 00:15:39,000
|
| 743 |
+
out of the box and in the very elegant way.
|
| 744 |
+
|
| 745 |
+
187
|
| 746 |
+
00:15:39,000 --> 00:15:45,000
|
| 747 |
+
Let's review an example in the separate package that is called Row Mappers.
|
| 748 |
+
|
| 749 |
+
188
|
| 750 |
+
00:15:45,000 --> 00:15:47,000
|
| 751 |
+
I implemented Row mapper.
|
| 752 |
+
|
| 753 |
+
189
|
| 754 |
+
00:15:48,000 --> 00:15:50,000
|
| 755 |
+
Everything is simple here.
|
| 756 |
+
|
| 757 |
+
190
|
| 758 |
+
00:15:50,000 --> 00:15:56,000
|
| 759 |
+
I declare a class that is called user row mapper that implements row mapper interface.
|
| 760 |
+
|
| 761 |
+
191
|
| 762 |
+
00:15:57,000 --> 00:16:03,000
|
| 763 |
+
This interface makes me implement one single method that is called map row.
|
| 764 |
+
|
| 765 |
+
192
|
| 766 |
+
00:16:03,000 --> 00:16:09,000
|
| 767 |
+
This method takes result set as method, argument and row numbers.
|
| 768 |
+
|
| 769 |
+
193
|
| 770 |
+
00:16:09,000 --> 00:16:16,000
|
| 771 |
+
Inside I will create user object and will do mapping between data from the result set and user object
|
| 772 |
+
|
| 773 |
+
194
|
| 774 |
+
00:16:16,000 --> 00:16:17,000
|
| 775 |
+
properties.
|
| 776 |
+
|
| 777 |
+
195
|
| 778 |
+
00:16:17,000 --> 00:16:21,000
|
| 779 |
+
I just return the user object from this method.
|
| 780 |
+
|
| 781 |
+
196
|
| 782 |
+
00:16:21,000 --> 00:16:25,000
|
| 783 |
+
Let me now open my user dialogue class here.
|
| 784 |
+
|
| 785 |
+
197
|
| 786 |
+
00:16:25,000 --> 00:16:28,000
|
| 787 |
+
I have method that is called Get User by ID.
|
| 788 |
+
|
| 789 |
+
198
|
| 790 |
+
00:16:28,000 --> 00:16:36,000
|
| 791 |
+
You can see that I use JDBC template to submit the SQL statement to extract all values from the user
|
| 792 |
+
|
| 793 |
+
199
|
| 794 |
+
00:16:36,000 --> 00:16:40,000
|
| 795 |
+
table where ID is equal to the one specified.
|
| 796 |
+
|
| 797 |
+
200
|
| 798 |
+
00:16:41,000 --> 00:16:49,000
|
| 799 |
+
According to the API, I need to pass an array with parameters and the second int array of argument
|
| 800 |
+
|
| 801 |
+
201
|
| 802 |
+
00:16:49,000 --> 00:16:50,000
|
| 803 |
+
types.
|
| 804 |
+
|
| 805 |
+
202
|
| 806 |
+
00:16:50,000 --> 00:16:52,000
|
| 807 |
+
Y int array.
|
| 808 |
+
|
| 809 |
+
203
|
| 810 |
+
00:16:52,000 --> 00:16:58,000
|
| 811 |
+
Because according to the API, I need to use constants from the java types class.
|
| 812 |
+
|
| 813 |
+
204
|
| 814 |
+
00:16:59,000 --> 00:17:03,000
|
| 815 |
+
I passed integer argument, so I just specify integer.
|
| 816 |
+
|
| 817 |
+
205
|
| 818 |
+
00:17:04,000 --> 00:17:11,000
|
| 819 |
+
I believe that it is clear and logical for you that there should be mapping between types in this array
|
| 820 |
+
|
| 821 |
+
206
|
| 822 |
+
00:17:11,000 --> 00:17:14,000
|
| 823 |
+
and actual types of arguments passed.
|
| 824 |
+
|
| 825 |
+
207
|
| 826 |
+
00:17:14,000 --> 00:17:20,000
|
| 827 |
+
And the fourth argument is our row mapper and we have user object returned.
|
| 828 |
+
|
| 829 |
+
208
|
| 830 |
+
00:17:20,000 --> 00:17:21,000
|
| 831 |
+
That's it.
|
| 832 |
+
|
| 833 |
+
209
|
| 834 |
+
00:17:22,000 --> 00:17:28,000
|
| 835 |
+
Just to remind you that in case you have any questions, please do not hesitate to ask your questions
|
| 836 |
+
|
| 837 |
+
210
|
| 838 |
+
00:17:28,000 --> 00:17:31,000
|
| 839 |
+
below the video and I will be happy to answer.
|
| 840 |
+
|
| 841 |
+
211
|
| 842 |
+
00:17:31,000 --> 00:17:33,000
|
| 843 |
+
Let's move on.
|
| 844 |
+
|
| 845 |
+
212
|
| 846 |
+
00:17:33,000 --> 00:17:41,000
|
| 847 |
+
So the only things that we still didn't review are examples with simple JDBC classes, the ones that
|
| 848 |
+
|
| 849 |
+
213
|
| 850 |
+
00:17:41,000 --> 00:17:49,000
|
| 851 |
+
we reviewed in theoretical Lesson two, namely simple JDBC insert and simple JDBC call.
|
| 852 |
+
|
| 853 |
+
214
|
| 854 |
+
00:17:50,000 --> 00:17:53,000
|
| 855 |
+
Let's start review from the simple JDBC insert.
|
| 856 |
+
|
| 857 |
+
215
|
| 858 |
+
00:17:53,000 --> 00:18:01,000
|
| 859 |
+
As you remember, I can use simple JDBC insert to generate the insert statement based on the configurations
|
| 860 |
+
|
| 861 |
+
216
|
| 862 |
+
00:18:01,000 --> 00:18:02,000
|
| 863 |
+
provided.
|
| 864 |
+
|
| 865 |
+
217
|
| 866 |
+
00:18:02,000 --> 00:18:08,000
|
| 867 |
+
All we need is to provide the table name column names and values.
|
| 868 |
+
|
| 869 |
+
218
|
| 870 |
+
00:18:08,000 --> 00:18:13,000
|
| 871 |
+
We already had method that inserts simple user data.
|
| 872 |
+
|
| 873 |
+
219
|
| 874 |
+
00:18:14,000 --> 00:18:20,000
|
| 875 |
+
I created the similar method, but just using simple jdbc insert object.
|
| 876 |
+
|
| 877 |
+
220
|
| 878 |
+
00:18:20,000 --> 00:18:27,000
|
| 879 |
+
I need to create object itself and you can see that I configure the table during the creation of the
|
| 880 |
+
|
| 881 |
+
221
|
| 882 |
+
00:18:27,000 --> 00:18:28,000
|
| 883 |
+
object.
|
| 884 |
+
|
| 885 |
+
222
|
| 886 |
+
00:18:28,000 --> 00:18:32,000
|
| 887 |
+
We're going to work with the user test table.
|
| 888 |
+
|
| 889 |
+
223
|
| 890 |
+
00:18:32,000 --> 00:18:37,000
|
| 891 |
+
After that I create map where I will put all required parameters.
|
| 892 |
+
|
| 893 |
+
224
|
| 894 |
+
00:18:37,000 --> 00:18:44,000
|
| 895 |
+
The key will be column name and the value will be the value that we want to insert.
|
| 896 |
+
|
| 897 |
+
225
|
| 898 |
+
00:18:44,000 --> 00:18:49,000
|
| 899 |
+
After that I just call execute method and pass all my parameters.
|
| 900 |
+
|
| 901 |
+
226
|
| 902 |
+
00:18:49,000 --> 00:18:56,000
|
| 903 |
+
Pay attention that using simple JDBC insert object, I don't create any SQL statements.
|
| 904 |
+
|
| 905 |
+
227
|
| 906 |
+
00:18:57,000 --> 00:18:58,000
|
| 907 |
+
That's how it works.
|
| 908 |
+
|
| 909 |
+
228
|
| 910 |
+
00:18:59,000 --> 00:19:02,000
|
| 911 |
+
You can see commanded line here.
|
| 912 |
+
|
| 913 |
+
229
|
| 914 |
+
00:19:02,000 --> 00:19:06,000
|
| 915 |
+
This is just a useful reminder about the API.
|
| 916 |
+
|
| 917 |
+
230
|
| 918 |
+
00:19:06,000 --> 00:19:14,000
|
| 919 |
+
Sometimes it is nice to get the primary key after insertion in order to proceed using this data further
|
| 920 |
+
|
| 921 |
+
231
|
| 922 |
+
00:19:14,000 --> 00:19:16,000
|
| 923 |
+
in our business logic.
|
| 924 |
+
|
| 925 |
+
232
|
| 926 |
+
00:19:16,000 --> 00:19:24,000
|
| 927 |
+
For this, you need to configure auto generated column and use method, execute and return key, just
|
| 928 |
+
|
| 929 |
+
233
|
| 930 |
+
00:19:24,000 --> 00:19:26,000
|
| 931 |
+
like you can see in the example here.
|
| 932 |
+
|
| 933 |
+
234
|
| 934 |
+
00:19:27,000 --> 00:19:35,000
|
| 935 |
+
And also we can pass data by using the map parameter source and being property parameter source.
|
| 936 |
+
|
| 937 |
+
235
|
| 938 |
+
00:19:36,000 --> 00:19:42,000
|
| 939 |
+
And the last but not the least for code examples for today is example of simple JDBC call.
|
| 940 |
+
|
| 941 |
+
236
|
| 942 |
+
00:19:42,000 --> 00:19:49,000
|
| 943 |
+
As you remember from previous lesson, object of this type is used to invoke stored procedure to invoke
|
| 944 |
+
|
| 945 |
+
237
|
| 946 |
+
00:19:49,000 --> 00:19:50,000
|
| 947 |
+
stored procedure.
|
| 948 |
+
|
| 949 |
+
238
|
| 950 |
+
00:19:50,000 --> 00:19:55,000
|
| 951 |
+
Let's make sure that stored procedure is created in the database.
|
| 952 |
+
|
| 953 |
+
239
|
| 954 |
+
00:19:55,000 --> 00:20:02,000
|
| 955 |
+
In the comments on top of the related demo method, I pasted code that you can execute in the database
|
| 956 |
+
|
| 957 |
+
240
|
| 958 |
+
00:20:02,000 --> 00:20:04,000
|
| 959 |
+
in order to create stored procedure.
|
| 960 |
+
|
| 961 |
+
241
|
| 962 |
+
00:20:05,000 --> 00:20:10,000
|
| 963 |
+
And once stored procedure is created, this code will work.
|
| 964 |
+
|
| 965 |
+
242
|
| 966 |
+
00:20:11,000 --> 00:20:17,000
|
| 967 |
+
I create object of simple JDBC call and I specify procedure name.
|
| 968 |
+
|
| 969 |
+
243
|
| 970 |
+
00:20:17,000 --> 00:20:20,000
|
| 971 |
+
This is the name of procedure that I've created before.
|
| 972 |
+
|
| 973 |
+
244
|
| 974 |
+
00:20:20,000 --> 00:20:24,000
|
| 975 |
+
The lesson in the database using the script above.
|
| 976 |
+
|
| 977 |
+
245
|
| 978 |
+
00:20:24,000 --> 00:20:29,000
|
| 979 |
+
Our procedure has in parameter and out parameters.
|
| 980 |
+
|
| 981 |
+
246
|
| 982 |
+
00:20:30,000 --> 00:20:32,000
|
| 983 |
+
Our in parameter is ID.
|
| 984 |
+
|
| 985 |
+
247
|
| 986 |
+
00:20:33,000 --> 00:20:36,000
|
| 987 |
+
Our out parameters are first name and last name.
|
| 988 |
+
|
| 989 |
+
248
|
| 990 |
+
00:20:37,000 --> 00:20:42,000
|
| 991 |
+
I create map parameters source and pass parameter into it.
|
| 992 |
+
|
| 993 |
+
249
|
| 994 |
+
00:20:43,000 --> 00:20:49,000
|
| 995 |
+
I use this parameter source object during the execution of the stored procedure here.
|
| 996 |
+
|
| 997 |
+
250
|
| 998 |
+
00:20:49,000 --> 00:20:58,000
|
| 999 |
+
As a result of execution, I receive map where string and names of output parameters and object is actually
|
| 1000 |
+
|
| 1001 |
+
251
|
| 1002 |
+
00:20:58,000 --> 00:21:00,000
|
| 1003 |
+
values of output parameters.
|
| 1004 |
+
|
| 1005 |
+
252
|
| 1006 |
+
00:21:00,000 --> 00:21:07,000
|
| 1007 |
+
I create user object and populate user with values that I received as out parameters.
|
| 1008 |
+
|
| 1009 |
+
253
|
| 1010 |
+
00:21:07,000 --> 00:21:13,000
|
| 1011 |
+
Just to remind you that in case you want to learn more about stored procedures, feel free to check
|
| 1012 |
+
|
| 1013 |
+
254
|
| 1014 |
+
00:21:13,000 --> 00:21:20,000
|
| 1015 |
+
my course Java from zero to first job and there you will find the separate lesson about stored procedures.
|
| 1016 |
+
|
| 1017 |
+
255
|
| 1018 |
+
00:21:20,000 --> 00:21:24,000
|
| 1019 |
+
Basically that's it about simple JDBC call.
|
| 1020 |
+
|
| 1021 |
+
256
|
| 1022 |
+
00:21:25,000 --> 00:21:29,000
|
| 1023 |
+
The only thing that is left is to make sure that everything works as expected.
|
| 1024 |
+
|
| 1025 |
+
257
|
| 1026 |
+
00:21:30,000 --> 00:21:33,000
|
| 1027 |
+
So create a service layer.
|
| 1028 |
+
|
| 1029 |
+
258
|
| 1030 |
+
00:21:33,000 --> 00:21:40,000
|
| 1031 |
+
This is just to help you understand how this DAO may be integrated in real life application.
|
| 1032 |
+
|
| 1033 |
+
259
|
| 1034 |
+
00:21:40,000 --> 00:21:46,000
|
| 1035 |
+
Most likely you are going to have some clos on the service layer where you will apply all your business
|
| 1036 |
+
|
| 1037 |
+
260
|
| 1038 |
+
00:21:46,000 --> 00:21:47,000
|
| 1039 |
+
logic.
|
| 1040 |
+
|
| 1041 |
+
261
|
| 1042 |
+
00:21:47,000 --> 00:21:51,000
|
| 1043 |
+
In my particular demo I created a new class in the service package.
|
| 1044 |
+
|
| 1045 |
+
262
|
| 1046 |
+
00:21:52,000 --> 00:21:55,000
|
| 1047 |
+
The class is called User Service JDBC Dao.
|
| 1048 |
+
|
| 1049 |
+
263
|
| 1050 |
+
00:21:56,000 --> 00:22:03,000
|
| 1051 |
+
I inject my DAO class here and on this level you can apply any application business logic that you need.
|
| 1052 |
+
|
| 1053 |
+
264
|
| 1054 |
+
00:22:04,000 --> 00:22:08,000
|
| 1055 |
+
And the service will be injected into the controller in Chan.
|
| 1056 |
+
|
| 1057 |
+
265
|
| 1058 |
+
00:22:08,000 --> 00:22:14,000
|
| 1059 |
+
I created another class called User Rest Controller JDBC Demo.
|
| 1060 |
+
|
| 1061 |
+
266
|
| 1062 |
+
00:22:14,000 --> 00:22:21,000
|
| 1063 |
+
Basically, I created here endpoints in order to be able to demo you all the methods that we have just
|
| 1064 |
+
|
| 1065 |
+
267
|
| 1066 |
+
00:22:21,000 --> 00:22:23,000
|
| 1067 |
+
reviewed in the user dao.
|
| 1068 |
+
|
| 1069 |
+
268
|
| 1070 |
+
00:22:23,000 --> 00:22:27,000
|
| 1071 |
+
I believe there is nothing new for you in this controller.
|
| 1072 |
+
|
| 1073 |
+
269
|
| 1074 |
+
00:22:27,000 --> 00:22:36,000
|
| 1075 |
+
Please make sure you don't skip lessons when you watch my course because I count on this few lessons
|
| 1076 |
+
|
| 1077 |
+
270
|
| 1078 |
+
00:22:36,000 --> 00:22:44,000
|
| 1079 |
+
ago we learned spring GPA and I showed you similar example of rest controller and explained that rest
|
| 1080 |
+
|
| 1081 |
+
271
|
| 1082 |
+
00:22:44,000 --> 00:22:51,000
|
| 1083 |
+
controller annotation is basically a combination of two annotations, controller and response body.
|
| 1084 |
+
|
| 1085 |
+
272
|
| 1086 |
+
00:22:52,000 --> 00:22:59,000
|
| 1087 |
+
Let me run the server and show you that all methods work as expected and that we receive the data that
|
| 1088 |
+
|
| 1089 |
+
273
|
| 1090 |
+
00:22:59,000 --> 00:23:00,000
|
| 1091 |
+
we expect to receive.
|
| 1092 |
+
|
| 1093 |
+
274
|
| 1094 |
+
00:23:01,000 --> 00:23:06,000
|
| 1095 |
+
First of all, here is how our user table looks like in the database.
|
| 1096 |
+
|
| 1097 |
+
275
|
| 1098 |
+
00:23:06,000 --> 00:23:11,000
|
| 1099 |
+
Three records and such columns, nothing extraordinary.
|
| 1100 |
+
|
| 1101 |
+
276
|
| 1102 |
+
00:23:11,000 --> 00:23:14,000
|
| 1103 |
+
Now let me open the web browser.
|
| 1104 |
+
|
| 1105 |
+
277
|
| 1106 |
+
00:23:14,000 --> 00:23:20,000
|
| 1107 |
+
In the web browser, I'm going to send requests and demo the methods in the sequence that we reviewed
|
| 1108 |
+
|
| 1109 |
+
278
|
| 1110 |
+
00:23:20,000 --> 00:23:21,000
|
| 1111 |
+
them.
|
| 1112 |
+
|
| 1113 |
+
279
|
| 1114 |
+
00:23:21,000 --> 00:23:26,000
|
| 1115 |
+
We're going to start with the first method where one extract total user count.
|
| 1116 |
+
|
| 1117 |
+
280
|
| 1118 |
+
00:23:27,000 --> 00:23:34,000
|
| 1119 |
+
This is a simple request that we created with a JDBC template, and as you can see, we receive value
|
| 1120 |
+
|
| 1121 |
+
281
|
| 1122 |
+
00:23:34,000 --> 00:23:40,000
|
| 1123 |
+
three as expected, because as you saw, I have three records in the user table.
|
| 1124 |
+
|
| 1125 |
+
282
|
| 1126 |
+
00:23:40,000 --> 00:23:46,000
|
| 1127 |
+
The next example is about adding sample user using JDBC template.
|
| 1128 |
+
|
| 1129 |
+
283
|
| 1130 |
+
00:23:49,000 --> 00:23:53,000
|
| 1131 |
+
After sending this request, I receive one.
|
| 1132 |
+
|
| 1133 |
+
284
|
| 1134 |
+
00:23:54,000 --> 00:23:56,000
|
| 1135 |
+
Because one record has been inserted.
|
| 1136 |
+
|
| 1137 |
+
285
|
| 1138 |
+
00:23:56,000 --> 00:24:01,000
|
| 1139 |
+
Let me also show you the database In the database.
|
| 1140 |
+
|
| 1141 |
+
286
|
| 1142 |
+
00:24:01,000 --> 00:24:04,000
|
| 1143 |
+
You can see that additional record is added.
|
| 1144 |
+
|
| 1145 |
+
287
|
| 1146 |
+
00:24:04,000 --> 00:24:09,000
|
| 1147 |
+
The next example is about using named parameter JDBC template.
|
| 1148 |
+
|
| 1149 |
+
288
|
| 1150 |
+
00:24:09,000 --> 00:24:13,000
|
| 1151 |
+
We are going to extract a last name by user ID.
|
| 1152 |
+
|
| 1153 |
+
289
|
| 1154 |
+
00:24:14,000 --> 00:24:19,000
|
| 1155 |
+
User ID seven has first name admin and last name admin.
|
| 1156 |
+
|
| 1157 |
+
290
|
| 1158 |
+
00:24:19,000 --> 00:24:23,000
|
| 1159 |
+
So everything works as expected.
|
| 1160 |
+
|
| 1161 |
+
291
|
| 1162 |
+
00:24:24,000 --> 00:24:29,000
|
| 1163 |
+
The next demo was about injecting parameters into the query using bin properties.
|
| 1164 |
+
|
| 1165 |
+
292
|
| 1166 |
+
00:24:29,000 --> 00:24:31,000
|
| 1167 |
+
SQL Parameter Source.
|
| 1168 |
+
|
| 1169 |
+
293
|
| 1170 |
+
00:24:31,000 --> 00:24:37,000
|
| 1171 |
+
I used user with a yy7 and I received the same last name.
|
| 1172 |
+
|
| 1173 |
+
294
|
| 1174 |
+
00:24:37,000 --> 00:24:44,000
|
| 1175 |
+
By the way, this trick is pretty useful when you need to inject multiple parameters into the SQL query
|
| 1176 |
+
|
| 1177 |
+
295
|
| 1178 |
+
00:24:44,000 --> 00:24:48,000
|
| 1179 |
+
in order to not list them all manually.
|
| 1180 |
+
|
| 1181 |
+
296
|
| 1182 |
+
00:24:49,000 --> 00:24:55,000
|
| 1183 |
+
You just pass bean and spring automatically matches parameters with properties.
|
| 1184 |
+
|
| 1185 |
+
297
|
| 1186 |
+
00:24:56,000 --> 00:25:03,000
|
| 1187 |
+
The next example is related to the case when you use feature of query execution in batch.
|
| 1188 |
+
|
| 1189 |
+
298
|
| 1190 |
+
00:25:03,000 --> 00:25:06,000
|
| 1191 |
+
Do you remember we implemented batch in set demo?
|
| 1192 |
+
|
| 1193 |
+
299
|
| 1194 |
+
00:25:06,000 --> 00:25:14,000
|
| 1195 |
+
So to review this code in action, you can send request to the following resource user batch and set
|
| 1196 |
+
|
| 1197 |
+
300
|
| 1198 |
+
00:25:14,000 --> 00:25:15,000
|
| 1199 |
+
demo.
|
| 1200 |
+
|
| 1201 |
+
301
|
| 1202 |
+
00:25:15,000 --> 00:25:21,000
|
| 1203 |
+
And after that we can open database our user test table.
|
| 1204 |
+
|
| 1205 |
+
302
|
| 1206 |
+
00:25:21,000 --> 00:25:26,000
|
| 1207 |
+
And just to be sure that new records were created in one batch.
|
| 1208 |
+
|
| 1209 |
+
303
|
| 1210 |
+
00:25:26,000 --> 00:25:33,000
|
| 1211 |
+
As I already mentioned, this should help you to increase performance in cases when you need to update
|
| 1212 |
+
|
| 1213 |
+
304
|
| 1214 |
+
00:25:33,000 --> 00:25:36,000
|
| 1215 |
+
the same table with multiple records.
|
| 1216 |
+
|
| 1217 |
+
305
|
| 1218 |
+
00:25:37,000 --> 00:25:41,000
|
| 1219 |
+
Let me now show you the example of user row mapper in action.
|
| 1220 |
+
|
| 1221 |
+
306
|
| 1222 |
+
00:25:41,000 --> 00:25:48,000
|
| 1223 |
+
So in the browser I send a request to the user JDBC demo seven.
|
| 1224 |
+
|
| 1225 |
+
307
|
| 1226 |
+
00:25:48,000 --> 00:25:56,000
|
| 1227 |
+
And as you can see, JSON is returned, user is converted into JSON because we configured our controller
|
| 1228 |
+
|
| 1229 |
+
308
|
| 1230 |
+
00:25:56,000 --> 00:26:01,000
|
| 1231 |
+
in such way it would write output directly into the response body.
|
| 1232 |
+
|
| 1233 |
+
309
|
| 1234 |
+
00:26:01,000 --> 00:26:09,000
|
| 1235 |
+
And taking into account that our method returns user object, it is automatically serialized into the
|
| 1236 |
+
|
| 1237 |
+
310
|
| 1238 |
+
00:26:09,000 --> 00:26:14,000
|
| 1239 |
+
JSON using JSON library that is added into the pom.xml.
|
| 1240 |
+
|
| 1241 |
+
311
|
| 1242 |
+
00:26:14,000 --> 00:26:22,000
|
| 1243 |
+
And as you can see, all fields that we populated inside our user role mapper are successfully populated.
|
| 1244 |
+
|
| 1245 |
+
312
|
| 1246 |
+
00:26:22,000 --> 00:26:24,000
|
| 1247 |
+
Also the danger lesson.
|
| 1248 |
+
|
| 1249 |
+
313
|
| 1250 |
+
00:26:24,000 --> 00:26:29,000
|
| 1251 |
+
We learned how to work with simple insert objects.
|
| 1252 |
+
|
| 1253 |
+
314
|
| 1254 |
+
00:26:29,000 --> 00:26:30,000
|
| 1255 |
+
Let's check the demo.
|
| 1256 |
+
|
| 1257 |
+
315
|
| 1258 |
+
00:26:31,000 --> 00:26:37,000
|
| 1259 |
+
We also implemented method that inserts the user with a simple JDBC insert.
|
| 1260 |
+
|
| 1261 |
+
316
|
| 1262 |
+
00:26:38,000 --> 00:26:42,000
|
| 1263 |
+
Let me send request to the foreign resource user.
|
| 1264 |
+
|
| 1265 |
+
317
|
| 1266 |
+
00:26:42,000 --> 00:26:44,000
|
| 1267 |
+
Add test user too.
|
| 1268 |
+
|
| 1269 |
+
318
|
| 1270 |
+
00:26:45,000 --> 00:26:50,000
|
| 1271 |
+
As you remember, for the sake of the demo, I did request to the user test table.
|
| 1272 |
+
|
| 1273 |
+
319
|
| 1274 |
+
00:26:50,000 --> 00:26:51,000
|
| 1275 |
+
Let's check.
|
| 1276 |
+
|
| 1277 |
+
320
|
| 1278 |
+
00:26:51,000 --> 00:26:53,000
|
| 1279 |
+
That record has been added.
|
| 1280 |
+
|
| 1281 |
+
321
|
| 1282 |
+
00:26:53,000 --> 00:26:55,000
|
| 1283 |
+
And here it is.
|
| 1284 |
+
|
| 1285 |
+
322
|
| 1286 |
+
00:26:55,000 --> 00:26:56,000
|
| 1287 |
+
The record has been added.
|
| 1288 |
+
|
| 1289 |
+
323
|
| 1290 |
+
00:26:57,000 --> 00:27:02,000
|
| 1291 |
+
And the last but not the least, is the demo of the stored procedure invocation.
|
| 1292 |
+
|
| 1293 |
+
324
|
| 1294 |
+
00:27:02,000 --> 00:27:07,000
|
| 1295 |
+
Let me send the request to the following resource user.
|
| 1296 |
+
|
| 1297 |
+
325
|
| 1298 |
+
00:27:07,000 --> 00:27:10,000
|
| 1299 |
+
Last Name Procedure demo seven.
|
| 1300 |
+
|
| 1301 |
+
326
|
| 1302 |
+
00:27:11,000 --> 00:27:17,000
|
| 1303 |
+
As you can see, we have populated on the first name and last name in our user object because our stored
|
| 1304 |
+
|
| 1305 |
+
327
|
| 1306 |
+
00:27:17,000 --> 00:27:21,000
|
| 1307 |
+
procedure has only two output parameters.
|
| 1308 |
+
|
| 1309 |
+
328
|
| 1310 |
+
00:27:21,000 --> 00:27:25,000
|
| 1311 |
+
Anyway, you can create any stored procedure you wish.
|
| 1312 |
+
|
| 1313 |
+
329
|
| 1314 |
+
00:27:25,000 --> 00:27:32,000
|
| 1315 |
+
The main thing is for you to understand the mechanics and how everything works under the hood.
|
| 1316 |
+
|
| 1317 |
+
330
|
| 1318 |
+
00:27:32,000 --> 00:27:37,000
|
| 1319 |
+
Knowing this, you can change parameters or queries by examples.
|
| 1320 |
+
|
| 1321 |
+
331
|
| 1322 |
+
00:27:37,000 --> 00:27:40,000
|
| 1323 |
+
It will be like a piece of cake for you.
|
| 1324 |
+
|
| 1325 |
+
332
|
| 1326 |
+
00:27:41,000 --> 00:27:44,000
|
| 1327 |
+
You're going to find source code examples in attachments to the video.
|
| 1328 |
+
|
| 1329 |
+
333
|
| 1330 |
+
00:27:45,000 --> 00:27:47,000
|
| 1331 |
+
Feel free to explore examples.
|
| 1332 |
+
|
| 1333 |
+
334
|
| 1334 |
+
00:27:47,000 --> 00:27:53,000
|
| 1335 |
+
Also, in case you have any questions, please put your questions below the video and I will be happy
|
| 1336 |
+
|
| 1337 |
+
335
|
| 1338 |
+
00:27:53,000 --> 00:27:54,000
|
| 1339 |
+
to answer.
|
| 1340 |
+
|
| 1341 |
+
336
|
| 1342 |
+
00:27:55,000 --> 00:27:59,000
|
| 1343 |
+
Now let's recap what we have learned in this lesson.
|
| 1344 |
+
|
| 1345 |
+
337
|
| 1346 |
+
00:28:00,000 --> 00:28:04,000
|
| 1347 |
+
Today we made overview of the spring JDBC packages.
|
| 1348 |
+
|
| 1349 |
+
338
|
| 1350 |
+
00:28:04,000 --> 00:28:08,000
|
| 1351 |
+
Now you know how the library is structured and where to search.
|
| 1352 |
+
|
| 1353 |
+
339
|
| 1354 |
+
00:28:08,000 --> 00:28:10,000
|
| 1355 |
+
What we learned.
|
| 1356 |
+
|
| 1357 |
+
340
|
| 1358 |
+
00:28:11,000 --> 00:28:12,000
|
| 1359 |
+
Spring JDBC configuration.
|
| 1360 |
+
|
| 1361 |
+
341
|
| 1362 |
+
00:28:12,000 --> 00:28:14,000
|
| 1363 |
+
Now you know everything.
|
| 1364 |
+
|
| 1365 |
+
342
|
| 1366 |
+
00:28:14,000 --> 00:28:19,000
|
| 1367 |
+
What we need to configure in order to start using features of spring JDBC.
|
| 1368 |
+
|
| 1369 |
+
343
|
| 1370 |
+
00:28:19,000 --> 00:28:27,000
|
| 1371 |
+
I showed you today a lot of practical code examples, namely examples with JDBC template with named
|
| 1372 |
+
|
| 1373 |
+
344
|
| 1374 |
+
00:28:27,000 --> 00:28:33,000
|
| 1375 |
+
parameter JDBC template simple JDBC insert and simple JDBC call.
|
| 1376 |
+
|
| 1377 |
+
345
|
| 1378 |
+
00:28:33,000 --> 00:28:39,000
|
| 1379 |
+
Also during the lesson I explained you what row mapper is and how to use it.
|
| 1380 |
+
|
| 1381 |
+
346
|
| 1382 |
+
00:28:39,000 --> 00:28:45,000
|
| 1383 |
+
And we learned how to make batch update with SQL parameter source utils class.
|
| 1384 |
+
|
| 1385 |
+
347
|
| 1386 |
+
00:28:46,000 --> 00:28:48,000
|
| 1387 |
+
That's all for this lesson.
|
| 1388 |
+
|
| 1389 |
+
348
|
| 1390 |
+
00:28:48,000 --> 00:28:50,000
|
| 1391 |
+
Thanks a lot for your attention.
|
| 1392 |
+
|
| 1393 |
+
349
|
| 1394 |
+
00:28:50,000 --> 00:28:53,000
|
| 1395 |
+
Have a great day and see you in the next lesson.
|
| 1396 |
+
|
88 - Spring JDBC/external-links.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
002 Source-code-of-examples-commit-with-changes-
|
| 3 |
+
https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/914fe50d4a0da192c913cd2d91560f3a03d60fa1
|
89 - ===== EXAM Spring JDBC - Online Shop =====/001 EXAM Spring JDBC - Online Shop.html
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
+
<title>EXAM Spring JDBC - Online Shop</title>
|
| 7 |
+
|
| 8 |
+
<style>
|
| 9 |
+
* {
|
| 10 |
+
box-sizing: border-box;
|
| 11 |
+
margin: 0;
|
| 12 |
+
padding: 0;
|
| 13 |
+
}
|
| 14 |
+
body {
|
| 15 |
+
font-family: var(--font-stack-text);
|
| 16 |
+
font-weight: 400;
|
| 17 |
+
line-height: 1.4;
|
| 18 |
+
font-size: 1.6rem;
|
| 19 |
+
color: #2d2f31;
|
| 20 |
+
}
|
| 21 |
+
.container {
|
| 22 |
+
position: relative;
|
| 23 |
+
height: 100%;
|
| 24 |
+
overflow-y: auto;
|
| 25 |
+
}
|
| 26 |
+
.content {
|
| 27 |
+
padding: 3.2rem 4.8rem;
|
| 28 |
+
word-break: break-word;
|
| 29 |
+
max-width: 69.6rem;
|
| 30 |
+
margin: 0 auto;
|
| 31 |
+
}
|
| 32 |
+
.heading {
|
| 33 |
+
margin-bottom: 24px;
|
| 34 |
+
font-family: -apple-system, BlinkMacSystemFont, Roboto, "Segoe UI", Helvetica, Arial, sans-serif,
|
| 35 |
+
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
| 36 |
+
font-weight: 700;
|
| 37 |
+
line-height: 1.2;
|
| 38 |
+
letter-spacing: 0;
|
| 39 |
+
font-size: 32px;
|
| 40 |
+
max-width: 36em;
|
| 41 |
+
}
|
| 42 |
+
.article-asset-container {
|
| 43 |
+
padding: 2.4rem;
|
| 44 |
+
}
|
| 45 |
+
.article-asset-container p {
|
| 46 |
+
font-size: 19px;
|
| 47 |
+
}
|
| 48 |
+
code {
|
| 49 |
+
background-color: #fff;
|
| 50 |
+
border: 1px solid #d1d7dc;
|
| 51 |
+
color: #b4690e;
|
| 52 |
+
font-size: 80%;
|
| 53 |
+
padding: 0.2rem 0.4rem;
|
| 54 |
+
font-family: sfmono-regular, Consolas, liberation mono, Menlo, Courier, monospace;
|
| 55 |
+
}
|
| 56 |
+
p {
|
| 57 |
+
font-weight: 400;
|
| 58 |
+
}
|
| 59 |
+
</style>
|
| 60 |
+
</head>
|
| 61 |
+
<body>
|
| 62 |
+
<div class="container">
|
| 63 |
+
<div class="content">
|
| 64 |
+
<div class="heading">EXAM Spring JDBC - Online Shop</div>
|
| 65 |
+
<div class="article-asset-container"><p>During the exam task you are going to take a template of the multimodule project - online shop, and integrate Spring JDBC into the persistence module of the application.</p><h4>Attachments:</h4><p>Exam Task - <a href="https://docs.google.com/document/d/1hUrihSGAdMao8_xp6IKkzniD7NdAzVyq5fmas1PyvJg/edit?usp=sharing" rel="noopener noreferrer" target="_blank">https://docs.google.com/document/d/1hUrihSGAdMao8_xp6IKkzniD7NdAzVyq5fmas1PyvJg/edit?usp=sharing</a></p></div>
|
| 66 |
+
</div>
|
| 67 |
+
</div>
|
| 68 |
+
</body>
|
| 69 |
+
</html>
|
90 - Spring AOP/001 Aspect Oriented Programming_en.srt
ADDED
|
@@ -0,0 +1,860 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:05,000 --> 00:00:06,000
|
| 3 |
+
Hello Tim.
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:06,000 --> 00:00:11,000
|
| 7 |
+
With this video lesson, we start a new and very important topic.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:11,000 --> 00:00:14,000
|
| 11 |
+
We are going to learn aspect oriented programming.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:14,000 --> 00:00:20,000
|
| 15 |
+
Today we will start our lesson from learning the definition of aspect oriented programming.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:20,000 --> 00:00:28,000
|
| 19 |
+
To understand what it is, I will explain you what cross-cutting concern is, What is an aspect?
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:28,000 --> 00:00:32,000
|
| 23 |
+
Why we need AOP and where to use it.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:32,000 --> 00:00:37,000
|
| 27 |
+
We will review the most common examples of using aspect oriented programming.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:38,000 --> 00:00:44,000
|
| 31 |
+
I will present you the most common and the most popular AOP implementations, and after that we are
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:44,000 --> 00:00:50,000
|
| 35 |
+
going to focus our attention on learning the key terms and concepts of the AOP.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:50,000 --> 00:01:00,000
|
| 39 |
+
Namely, I am going to explain you what joint point is Pointcut advice Introduction Target Object Interceptor,
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:01:00,000 --> 00:01:08,000
|
| 43 |
+
AOP Proxy and we even and at the end of the lesson we are going to summarize the advantages and disadvantages
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:01:08,000 --> 00:01:08,000
|
| 47 |
+
of the AOP.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:01:09,000 --> 00:01:11,000
|
| 51 |
+
Let's start our lesson.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:01:12,000 --> 00:01:18,000
|
| 55 |
+
Let's start from the overview of and understanding better what it actually is.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:01:18,000 --> 00:01:23,000
|
| 59 |
+
As you may already guess, AOP stands for aspect oriented programming.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:01:23,000 --> 00:01:27,000
|
| 63 |
+
This is not the easiest topic for understanding, to be honest.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:01:27,000 --> 00:01:30,000
|
| 67 |
+
That's why we learn it just now.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:01:30,000 --> 00:01:38,000
|
| 71 |
+
Also, it is relatively rare used directly, but it is very often used in different frameworks under
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:01:38,000 --> 00:01:39,000
|
| 75 |
+
the hood.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:01:39,000 --> 00:01:44,000
|
| 79 |
+
And also this often pops up as a topic during the technical interview.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:01:45,000 --> 00:01:52,000
|
| 83 |
+
AOP is a paradigm that supposed to increase the modularity of the different parts of an application
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:01:52,000 --> 00:01:54,000
|
| 87 |
+
by separating cross-cutting concerns.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:01:55,000 --> 00:02:00,000
|
| 91 |
+
The most of my students often ask me what are cross-cutting concerns?
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:02:01,000 --> 00:02:03,000
|
| 95 |
+
Okay, let me answer that.
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:02:03,000 --> 00:02:11,000
|
| 99 |
+
Cross-cutting concern is an aspect of a program that affects several modules without the possibility
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:02:11,000 --> 00:02:14,000
|
| 103 |
+
of being encapsulated in any of them.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:02:14,000 --> 00:02:22,000
|
| 107 |
+
For example, if writing an application for handling medical records, the indexing of such records
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:02:22,000 --> 00:02:31,000
|
| 111 |
+
is a core concern while logging a history of changes to the record database or user database or an authentication
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:02:31,000 --> 00:02:38,000
|
| 115 |
+
system would be cross-cutting concerns since they interact with more parts of the program.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:02:38,000 --> 00:02:45,000
|
| 119 |
+
So AOP breaks the program logic into separate parts that are called concerns.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:02:45,000 --> 00:02:53,000
|
| 123 |
+
The functions that span multiple points of an application, unnamed cross-cutting concerns and these
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:02:53,000 --> 00:02:59,000
|
| 127 |
+
cross-cutting concerns are conceptually separate from the application's business logic.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:03:00,000 --> 00:03:07,000
|
| 131 |
+
A cross-cutting concern is a type of concern that has the power to impact the entire application and
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:03:07,000 --> 00:03:12,000
|
| 135 |
+
should always be centralized in one location in the program as possible.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:03:12,000 --> 00:03:18,000
|
| 139 |
+
But probably now you have another question What is an aspect of a program?
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:03:19,000 --> 00:03:26,000
|
| 143 |
+
An aspect of a program is a feature linked to many other parts of the program, but which is not related
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:03:26,000 --> 00:03:28,000
|
| 147 |
+
to the program's primary function.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:03:29,000 --> 00:03:37,000
|
| 151 |
+
An aspect crosscuts the program's core concerns, therefore violating its separation of concerns that
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:03:37,000 --> 00:03:40,000
|
| 155 |
+
tries to encapsulate unrelated functions.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:03:40,000 --> 00:03:46,000
|
| 159 |
+
And again, the most clear example in my opinion, is about login.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:03:46,000 --> 00:03:51,000
|
| 163 |
+
For example, login code can crosscut many modules.
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:03:51,000 --> 00:03:57,000
|
| 167 |
+
The aspect of login should be separate from the functional concerns of the module.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:03:57,000 --> 00:03:58,000
|
| 171 |
+
It crosscuts.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:03:59,000 --> 00:04:01,000
|
| 175 |
+
What are the examples?
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:04:01,000 --> 00:04:05,000
|
| 179 |
+
There are various useful examples of aspects in software development.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:04:05,000 --> 00:04:14,000
|
| 183 |
+
Like, for example, login, auditing, data validation, declarative transactions, security caching,
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:04:14,000 --> 00:04:15,000
|
| 187 |
+
etcetera.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:04:15,000 --> 00:04:16,000
|
| 191 |
+
Is it clear?
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:04:17,000 --> 00:04:20,000
|
| 195 |
+
So let's get back to again.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:04:20,000 --> 00:04:26,000
|
| 199 |
+
And the question is how it is actually done and how it is implemented.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:04:26,000 --> 00:04:33,000
|
| 203 |
+
The AOP is implemented by adding additional behavior to the existing code without making changes to
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:04:33,000 --> 00:04:35,000
|
| 207 |
+
the original code.
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:04:35,000 --> 00:04:38,000
|
| 211 |
+
Sounds interesting already, isn't it?
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:04:39,000 --> 00:04:45,000
|
| 215 |
+
So basically, in order to add some additional functionality to some methods, you don't need to open
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:04:45,000 --> 00:04:49,000
|
| 219 |
+
the class and actually fix the source code.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:04:49,000 --> 00:04:54,000
|
| 223 |
+
You can add additional functionality actually without editing the source code.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:04:54,000 --> 00:04:56,000
|
| 227 |
+
Sounds like magic.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:04:56,000 --> 00:04:57,000
|
| 231 |
+
Don't you think so?
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:04:58,000 --> 00:05:07,000
|
| 235 |
+
We can also compare AOP with OP object oriented programming to understand better.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:05:08,000 --> 00:05:16,000
|
| 239 |
+
The key unit of modularity in AOP is the class, whereas in aspect oriented programming, the unit of
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:05:16,000 --> 00:05:19,000
|
| 243 |
+
modularity is the aspect.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:05:19,000 --> 00:05:27,000
|
| 247 |
+
AOP allows you to decouple cross-cutting concerns from the objects that they affect in the development
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:05:27,000 --> 00:05:27,000
|
| 251 |
+
process.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:05:28,000 --> 00:05:30,000
|
| 255 |
+
Now let me explain you.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:05:30,000 --> 00:05:32,000
|
| 259 |
+
Why do we need AOP?
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:05:32,000 --> 00:05:38,000
|
| 263 |
+
I believe that you already had a chance to understand the advantages that we expect to get by using
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:05:38,000 --> 00:05:39,000
|
| 267 |
+
AOP approach.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:05:39,000 --> 00:05:45,000
|
| 271 |
+
But let me elaborate a little bit more and explain you based on examples.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:05:45,000 --> 00:05:51,000
|
| 275 |
+
Imagine that we have the following test class with the three methods that you can see on the screen.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:05:52,000 --> 00:05:59,000
|
| 279 |
+
And imagine that you need to ensure a login after each method in this class is completed without AOP.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:05:59,000 --> 00:06:00,000
|
| 283 |
+
What would you do?
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:06:01,000 --> 00:06:07,000
|
| 287 |
+
You would create instance of logger and you would adjust source code of each method by adding logging
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:06:07,000 --> 00:06:08,000
|
| 291 |
+
in each method.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:06:08,000 --> 00:06:09,000
|
| 295 |
+
Is that correct?
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:06:10,000 --> 00:06:13,000
|
| 299 |
+
With aspect oriented programming approach.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:06:13,000 --> 00:06:16,000
|
| 303 |
+
You don't need to adjust each method.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:06:16,000 --> 00:06:22,000
|
| 307 |
+
You just need to declare, let's say, rules when and what should be executed.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:06:23,000 --> 00:06:26,000
|
| 311 |
+
Let's imagine that rule sounds like this.
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:06:26,000 --> 00:06:30,000
|
| 315 |
+
Log the method name according to the predefined pattern.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:06:30,000 --> 00:06:32,000
|
| 319 |
+
One method is completed.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:06:32,000 --> 00:06:42,000
|
| 323 |
+
So to sum it up when we should use AOP, it can be used when we need allow users to implement custom
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:06:42,000 --> 00:06:43,000
|
| 327 |
+
elements.
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:06:43,000 --> 00:06:49,000
|
| 331 |
+
These elements can be really helpful for adding some additional features and functionalities that were
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:06:49,000 --> 00:06:52,000
|
| 335 |
+
not present in the software at the beginning.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:06:53,000 --> 00:07:01,000
|
| 339 |
+
I believe you understand that AUP is an approach and to implement AUP in your program, you need some
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:07:01,000 --> 00:07:01,000
|
| 343 |
+
tool.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:07:02,000 --> 00:07:07,000
|
| 347 |
+
There are different libraries that can help you to implement in Java.
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:07:07,000 --> 00:07:12,000
|
| 351 |
+
They are aspect Spring, AOP, JBoss, AOP.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:07:13,000 --> 00:07:20,000
|
| 355 |
+
All implementations use the same terminology that we are going to learn today, but the details of implementation
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:07:20,000 --> 00:07:22,000
|
| 359 |
+
can be different.
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:07:22,000 --> 00:07:28,000
|
| 363 |
+
Anyway, in my opinion aspect and spring AOP the most popular ones.
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:07:29,000 --> 00:07:34,000
|
| 367 |
+
Okay, let's learn the key terms and concepts that are widely used in AOP.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:07:34,000 --> 00:07:37,000
|
| 371 |
+
No matter what implementation do you use?
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:07:38,000 --> 00:07:43,000
|
| 375 |
+
So on this slide, you can see the key concepts.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:07:43,000 --> 00:07:45,000
|
| 379 |
+
They are joint point.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:07:45,000 --> 00:07:48,000
|
| 383 |
+
Point Cut Advice.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:07:48,000 --> 00:07:54,000
|
| 387 |
+
Introduction Target Object aspect Interceptor.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:07:54,000 --> 00:07:57,000
|
| 391 |
+
AOP Proxy even.
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:07:58,000 --> 00:08:03,000
|
| 395 |
+
Let's now spend some time understanding each of these key concepts.
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:08:03,000 --> 00:08:04,000
|
| 399 |
+
Let's go one by one.
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:08:05,000 --> 00:08:08,000
|
| 403 |
+
The first one in our list is Joint Point.
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:08:09,000 --> 00:08:16,000
|
| 407 |
+
Durant point is any point in your program, such as method execution, exception, handling, field
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:08:16,000 --> 00:08:18,000
|
| 411 |
+
access, etcetera.
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:08:18,000 --> 00:08:23,000
|
| 415 |
+
The different libraries that you can use to apply your approach.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:08:23,000 --> 00:08:29,000
|
| 419 |
+
But if we talk about spring AOP, for example, it supports only massive execution.
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:08:29,000 --> 00:08:30,000
|
| 423 |
+
Join point.
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:08:31,000 --> 00:08:40,000
|
| 427 |
+
Join point symbolizes a point in your application where you can easily plug in the aspect of your software.
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:08:41,000 --> 00:08:42,000
|
| 431 |
+
Point cut.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:08:43,000 --> 00:08:46,000
|
| 435 |
+
Let's understand now what a point cut is.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:08:46,000 --> 00:08:51,000
|
| 439 |
+
It is an expression language of AOP that matches join points.
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:08:52,000 --> 00:08:59,000
|
| 443 |
+
Point cut is an expression that is matched with joint points to determine whether advice needs to be
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:08:59,000 --> 00:09:01,000
|
| 447 |
+
executed or not.
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:09:01,000 --> 00:09:07,000
|
| 451 |
+
Point cut uses different kinds of expressions that are matched with the joint points.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:09:07,000 --> 00:09:13,000
|
| 455 |
+
For example, Spring Framework uses the point cut expression language.
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:09:13,000 --> 00:09:18,000
|
| 459 |
+
The next key concept from our list is advice.
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:09:19,000 --> 00:09:24,000
|
| 463 |
+
Advice represents an action taken by an aspect at a particular joint point.
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:09:24,000 --> 00:09:27,000
|
| 467 |
+
If you don't understand the statement, don't worry.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:09:27,000 --> 00:09:31,000
|
| 471 |
+
I will try to explain advice in different ways now.
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:09:32,000 --> 00:09:38,000
|
| 475 |
+
Advices are actions taken for a particular joint point in terms of programming.
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:09:38,000 --> 00:09:47,000
|
| 479 |
+
The methods that get executed when a certain joint point with matching point is reached in the application.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:09:48,000 --> 00:09:52,000
|
| 483 |
+
You can think of advices as servlet filters, for example.
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:09:53,000 --> 00:09:58,000
|
| 487 |
+
Based on the execution strategy of advice, there are the following types.
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:09:58,000 --> 00:10:05,000
|
| 491 |
+
Before advice, these advices run before the execution of join point.
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:10:06,000 --> 00:10:14,000
|
| 495 |
+
After returning advice in case you want to execute advice only if the join point method executes normally,
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:10:14,000 --> 00:10:18,000
|
| 499 |
+
then you should use after returning advice.
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:10:18,000 --> 00:10:24,000
|
| 503 |
+
We can use after returning annotation to mark a method as after returning advice.
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:10:24,000 --> 00:10:32,000
|
| 507 |
+
After throwing advice, this advice gets executed only when join point method throws an exception.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:10:33,000 --> 00:10:36,000
|
| 511 |
+
We can use it to roll back the transaction declaratively.
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:10:37,000 --> 00:10:46,000
|
| 515 |
+
After finally advice and advice that gets executed after the joint point finished execution, whether
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:10:46,000 --> 00:10:48,000
|
| 519 |
+
normally or by throwing an exception.
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:10:49,000 --> 00:10:51,000
|
| 523 |
+
Around the device.
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:10:51,000 --> 00:10:54,000
|
| 527 |
+
This is the most important and powerful advice.
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:10:54,000 --> 00:11:01,000
|
| 531 |
+
This advice surrounds the join point method, and we can also choose whether to execute the join point
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:11:01,000 --> 00:11:03,000
|
| 535 |
+
method or not.
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:11:03,000 --> 00:11:10,000
|
| 539 |
+
We can write advice code that gets executed before and after the execution of the join point method.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:11:11,000 --> 00:11:18,000
|
| 543 |
+
It is the responsibility of around advice to invoke the join point method and return values if the market
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:11:18,000 --> 00:11:20,000
|
| 547 |
+
returns something.
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:11:21,000 --> 00:11:22,000
|
| 551 |
+
Introduction.
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:11:22,000 --> 00:11:28,000
|
| 555 |
+
Introduction concept means introduction of additional masses and fields for a type.
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:11:29,000 --> 00:11:34,000
|
| 559 |
+
It allows you to introduce new interface to any advanced object.
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:11:35,000 --> 00:11:43,000
|
| 563 |
+
An introduction is another term in spring that helps you to add new methods or features to the existing
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:11:43,000 --> 00:11:43,000
|
| 567 |
+
classes.
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:11:43,000 --> 00:11:51,000
|
| 571 |
+
It basically means the introduction of additional methods and domains for a particular type as per the
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:11:51,000 --> 00:11:53,000
|
| 575 |
+
requirements of the software.
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:11:53,000 --> 00:12:00,000
|
| 579 |
+
It allows you to introduce a new interface to any advanced object for your particular system.
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:12:00,000 --> 00:12:03,000
|
| 583 |
+
So in short, about introduction.
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:12:03,000 --> 00:12:07,000
|
| 587 |
+
Declaring additional methods or fields on behalf of a type.
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:12:08,000 --> 00:12:17,000
|
| 591 |
+
Spring allows you to introduce new interfaces and the corresponding implementation to any advanced object.
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:12:17,000 --> 00:12:25,000
|
| 595 |
+
For example, you could use an introduction to make a bean implement and is modified interface to simplify
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:12:25,000 --> 00:12:26,000
|
| 599 |
+
caching.
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:12:27,000 --> 00:12:31,000
|
| 603 |
+
The next important concept in AOP is target object.
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:12:31,000 --> 00:12:33,000
|
| 607 |
+
What is it?
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:12:33,000 --> 00:12:37,000
|
| 611 |
+
This is the object on which advices are applied.
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:12:37,000 --> 00:12:41,000
|
| 615 |
+
Our business object is it contains some business logic.
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:12:41,000 --> 00:12:46,000
|
| 619 |
+
In spring it is also known as proxied object.
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:12:46,000 --> 00:12:53,000
|
| 623 |
+
That is because target object in spring AOP is implemented using runtime proxies.
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:12:53,000 --> 00:12:57,000
|
| 627 |
+
So this object is always a proxied object.
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:12:57,000 --> 00:13:06,000
|
| 631 |
+
It means that a subclass is created at the runtime, whereas the target method is overridden and device
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:13:06,000 --> 00:13:10,000
|
| 635 |
+
is included based on its configuration.
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:13:10,000 --> 00:13:11,000
|
| 639 |
+
Is it clear?
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:13:12,000 --> 00:13:14,000
|
| 643 |
+
In order to apply the advice.
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:13:14,000 --> 00:13:19,000
|
| 647 |
+
The method that is invoked on target object is overridden.
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:13:19,000 --> 00:13:24,000
|
| 651 |
+
Well already learned such key concepts in as aspect.
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:13:24,000 --> 00:13:26,000
|
| 655 |
+
But just to recap.
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:13:26,000 --> 00:13:29,000
|
| 659 |
+
Taking into account, we are looking through all the key concepts.
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:13:29,000 --> 00:13:32,000
|
| 663 |
+
First of all, aspect it is a class.
|
| 664 |
+
|
| 665 |
+
167
|
| 666 |
+
00:13:32,000 --> 00:13:36,000
|
| 667 |
+
This class contains advices during points.
|
| 668 |
+
|
| 669 |
+
168
|
| 670 |
+
00:13:36,000 --> 00:13:37,000
|
| 671 |
+
ET cetera.
|
| 672 |
+
|
| 673 |
+
169
|
| 674 |
+
00:13:37,000 --> 00:13:44,000
|
| 675 |
+
Aspect can be a normal class configured through spring XML configuration, or we can use spring aspect
|
| 676 |
+
|
| 677 |
+
170
|
| 678 |
+
00:13:45,000 --> 00:13:48,000
|
| 679 |
+
integration to define a class as aspect.
|
| 680 |
+
|
| 681 |
+
171
|
| 682 |
+
00:13:48,000 --> 00:13:50,000
|
| 683 |
+
Using aspect annotation.
|
| 684 |
+
|
| 685 |
+
172
|
| 686 |
+
00:13:50,000 --> 00:13:57,000
|
| 687 |
+
An aspect is a modularization of a concern that cuts across multiple classes.
|
| 688 |
+
|
| 689 |
+
173
|
| 690 |
+
00:13:57,000 --> 00:14:03,000
|
| 691 |
+
For example, the class that contains after returning advice can be named aspect.
|
| 692 |
+
|
| 693 |
+
174
|
| 694 |
+
00:14:03,000 --> 00:14:09,000
|
| 695 |
+
An application can have any number of aspects depending on the requirement of the software.
|
| 696 |
+
|
| 697 |
+
175
|
| 698 |
+
00:14:10,000 --> 00:14:14,000
|
| 699 |
+
Now let's learn what an interceptor is.
|
| 700 |
+
|
| 701 |
+
176
|
| 702 |
+
00:14:14,000 --> 00:14:20,000
|
| 703 |
+
In simple words, it is an aspect that contains only one advice.
|
| 704 |
+
|
| 705 |
+
177
|
| 706 |
+
00:14:20,000 --> 00:14:23,000
|
| 707 |
+
The next concept is AOP Proxy.
|
| 708 |
+
|
| 709 |
+
178
|
| 710 |
+
00:14:24,000 --> 00:14:31,000
|
| 711 |
+
AOP Proxy is used to implement aspect contracts created by AOP framework.
|
| 712 |
+
|
| 713 |
+
179
|
| 714 |
+
00:14:31,000 --> 00:14:38,000
|
| 715 |
+
It will be a dynamic proxy or CG lip proxy in spring framework.
|
| 716 |
+
|
| 717 |
+
180
|
| 718 |
+
00:14:38,000 --> 00:14:47,000
|
| 719 |
+
Spring implementation uses JDK Dynamic proxy to create the proxy classes with target classes and advice
|
| 720 |
+
|
| 721 |
+
181
|
| 722 |
+
00:14:47,000 --> 00:14:48,000
|
| 723 |
+
invocations.
|
| 724 |
+
|
| 725 |
+
182
|
| 726 |
+
00:14:48,000 --> 00:14:51,000
|
| 727 |
+
These are called AOP proxy classes.
|
| 728 |
+
|
| 729 |
+
183
|
| 730 |
+
00:14:51,000 --> 00:14:59,000
|
| 731 |
+
We can also use CG lip proxy by adding it as a dependency in the spring AOP project.
|
| 732 |
+
|
| 733 |
+
184
|
| 734 |
+
00:15:00,000 --> 00:15:03,000
|
| 735 |
+
And the last but not the least from our list is we even.
|
| 736 |
+
|
| 737 |
+
185
|
| 738 |
+
00:15:05,000 --> 00:15:13,000
|
| 739 |
+
Leven is a process of linking aspect with other application types or objects to create an advanced object.
|
| 740 |
+
|
| 741 |
+
186
|
| 742 |
+
00:15:13,000 --> 00:15:18,000
|
| 743 |
+
We even can be done at compile time, load time or runtime.
|
| 744 |
+
|
| 745 |
+
187
|
| 746 |
+
00:15:19,000 --> 00:15:23,000
|
| 747 |
+
Spring performs even at runtime.
|
| 748 |
+
|
| 749 |
+
188
|
| 750 |
+
00:15:24,000 --> 00:15:29,000
|
| 751 |
+
And the last thing that I would like to talk with you today is about advantages and disadvantages of
|
| 752 |
+
|
| 753 |
+
189
|
| 754 |
+
00:15:29,000 --> 00:15:31,000
|
| 755 |
+
the aspect oriented programming.
|
| 756 |
+
|
| 757 |
+
190
|
| 758 |
+
00:15:32,000 --> 00:15:35,000
|
| 759 |
+
And one advantages it is worth to mention the following ones.
|
| 760 |
+
|
| 761 |
+
191
|
| 762 |
+
00:15:36,000 --> 00:15:39,000
|
| 763 |
+
AOP respects modularity.
|
| 764 |
+
|
| 765 |
+
192
|
| 766 |
+
00:15:39,000 --> 00:15:42,000
|
| 767 |
+
It reduces the coupling of dependencies.
|
| 768 |
+
|
| 769 |
+
193
|
| 770 |
+
00:15:43,000 --> 00:15:47,000
|
| 771 |
+
It makes code more readable, reusable and maintainable.
|
| 772 |
+
|
| 773 |
+
194
|
| 774 |
+
00:15:48,000 --> 00:15:53,000
|
| 775 |
+
If we want to discuss disadvantages, then we should mention the following ones.
|
| 776 |
+
|
| 777 |
+
195
|
| 778 |
+
00:15:54,000 --> 00:16:02,000
|
| 779 |
+
The bargain can be more difficult because there is more code than I can see at the beginning to configure
|
| 780 |
+
|
| 781 |
+
196
|
| 782 |
+
00:16:02,000 --> 00:16:03,000
|
| 783 |
+
breakpoints properly.
|
| 784 |
+
|
| 785 |
+
197
|
| 786 |
+
00:16:04,000 --> 00:16:09,000
|
| 787 |
+
A requires discipline to refrain from overuse.
|
| 788 |
+
|
| 789 |
+
198
|
| 790 |
+
00:16:10,000 --> 00:16:18,000
|
| 791 |
+
In general, aspect oriented programming can be called as dark art because it can perform some black
|
| 792 |
+
|
| 793 |
+
199
|
| 794 |
+
00:16:18,000 --> 00:16:19,000
|
| 795 |
+
magic behind the scenes.
|
| 796 |
+
|
| 797 |
+
200
|
| 798 |
+
00:16:19,000 --> 00:16:28,000
|
| 799 |
+
In the old world and in your code, I believe you can understand that with AOP, we can change the way
|
| 800 |
+
|
| 801 |
+
201
|
| 802 |
+
00:16:28,000 --> 00:16:34,000
|
| 803 |
+
of method execution, replace the result, or even prevent it from running at all.
|
| 804 |
+
|
| 805 |
+
202
|
| 806 |
+
00:16:35,000 --> 00:16:45,000
|
| 807 |
+
Taking into account APIs such power you always should remember about it and use with caution and understanding
|
| 808 |
+
|
| 809 |
+
203
|
| 810 |
+
00:16:45,000 --> 00:16:52,000
|
| 811 |
+
and necessary use of in your application can be dangerous and result into unexpected errors.
|
| 812 |
+
|
| 813 |
+
204
|
| 814 |
+
00:16:53,000 --> 00:16:55,000
|
| 815 |
+
That's all what I wanted to discuss with you.
|
| 816 |
+
|
| 817 |
+
205
|
| 818 |
+
00:16:56,000 --> 00:16:59,000
|
| 819 |
+
Let's recap what we have learned in this lesson.
|
| 820 |
+
|
| 821 |
+
206
|
| 822 |
+
00:17:00,000 --> 00:17:05,000
|
| 823 |
+
So the day we learned what an aspect oriented programming is.
|
| 824 |
+
|
| 825 |
+
207
|
| 826 |
+
00:17:06,000 --> 00:17:11,000
|
| 827 |
+
I explained you what cross-cutting concern and what aspect actually are.
|
| 828 |
+
|
| 829 |
+
208
|
| 830 |
+
00:17:11,000 --> 00:17:16,000
|
| 831 |
+
We learned why we need AOP and where to use AOP.
|
| 832 |
+
|
| 833 |
+
209
|
| 834 |
+
00:17:17,000 --> 00:17:20,000
|
| 835 |
+
I showed you main AOP implementations.
|
| 836 |
+
|
| 837 |
+
210
|
| 838 |
+
00:17:20,000 --> 00:17:29,000
|
| 839 |
+
We learned key terms and concepts of AOP like Joint Point, point cut and voice introduction, target
|
| 840 |
+
|
| 841 |
+
211
|
| 842 |
+
00:17:29,000 --> 00:17:33,000
|
| 843 |
+
object Interceptor, AOP, proxy weaving.
|
| 844 |
+
|
| 845 |
+
212
|
| 846 |
+
00:17:33,000 --> 00:17:39,000
|
| 847 |
+
And at the end of the lesson, we learned the advantages and disadvantages of the AOP.
|
| 848 |
+
|
| 849 |
+
213
|
| 850 |
+
00:17:40,000 --> 00:17:41,000
|
| 851 |
+
That's all for this lesson.
|
| 852 |
+
|
| 853 |
+
214
|
| 854 |
+
00:17:42,000 --> 00:17:43,000
|
| 855 |
+
Thanks a lot for your attention.
|
| 856 |
+
|
| 857 |
+
215
|
| 858 |
+
00:17:43,000 --> 00:17:47,000
|
| 859 |
+
Have a great day and see you in the next lesson.
|
| 860 |
+
|
90 - Spring AOP/002 Source-code-of-examples-commit-with-changes-.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/ab0084445a16c0c8897cc80308c28817d9dace8a
|
90 - Spring AOP/002 Spring AOP with AspectJ Practice_en.srt
ADDED
|
@@ -0,0 +1,1076 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:05,000 --> 00:00:06,000
|
| 3 |
+
Hello Tim.
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:06,000 --> 00:00:09,000
|
| 7 |
+
We continue learning aspect oriented programming.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:09,000 --> 00:00:15,000
|
| 11 |
+
I hope that you watched previous theoretical lesson about AOP in this video.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:15,000 --> 00:00:21,000
|
| 15 |
+
We are going to have a lot of practical examples with Spring, AOP and aspect J.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:22,000 --> 00:00:28,000
|
| 19 |
+
We're going to start our lesson from review of required dependencies that we need to add into our project.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:29,000 --> 00:00:34,000
|
| 23 |
+
Together we are going to create aspect and configure point cards and advices.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:34,000 --> 00:00:41,000
|
| 27 |
+
I'm going to show you different pointcut designators that can be used and recognized by spring AOP.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:42,000 --> 00:00:50,000
|
| 31 |
+
Also, I will show you how to enable aspect configuration support with enable aspect Autoproxy annotation
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:50,000 --> 00:00:53,000
|
| 35 |
+
and after everything will be configured.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:53,000 --> 00:00:58,000
|
| 39 |
+
We are going to see live examples and how all the code works together.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:58,000 --> 00:01:05,000
|
| 43 |
+
Let's start our lesson and as I already mentioned today, we are going to have a lesson full of practical
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:01:05,000 --> 00:01:06,000
|
| 47 |
+
examples.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:01:06,000 --> 00:01:08,000
|
| 51 |
+
So let me start screen sharing.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:01:09,000 --> 00:01:14,000
|
| 55 |
+
As always, you can find the reference to the source code examples in attachments to the video.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:01:14,000 --> 00:01:21,000
|
| 59 |
+
And in case you have any questions, please let me know in comments below the video.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:01:21,000 --> 00:01:28,000
|
| 63 |
+
As we already learned in the previous lesson aspect, oriented programming complements object oriented
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:01:28,000 --> 00:01:33,000
|
| 67 |
+
programming by providing another way of thinking about program structure.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:01:33,000 --> 00:01:38,000
|
| 71 |
+
The key unit of modularity in OOP is the class.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:01:38,000 --> 00:01:42,000
|
| 75 |
+
Whereas in AOP, the unit of modularity is the aspect.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:01:43,000 --> 00:01:47,000
|
| 79 |
+
Let's start from adding required dependencies.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:01:47,000 --> 00:01:55,000
|
| 83 |
+
I opened pom.xml, so there is a separate library spring AOP that contains interfaces and classes by
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:01:55,000 --> 00:01:59,000
|
| 87 |
+
implementing which you can configure advices that you need.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:01:59,000 --> 00:02:08,000
|
| 91 |
+
But I can say that approach based on aspect annotations is popular and so widespread that in my personal
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:02:08,000 --> 00:02:15,000
|
| 95 |
+
experience this is dominated approach of configuring aspects even in spring based applications.
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:02:15,000 --> 00:02:22,000
|
| 99 |
+
Spring framework recognizes aspect annotations and introduces aspect support.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:02:22,000 --> 00:02:28,000
|
| 103 |
+
That's why in this particular practical example we will add aspect dependencies only.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:02:29,000 --> 00:02:36,000
|
| 107 |
+
Aspect refers to a style of declaring aspects as a regular Java classes annotated with annotations.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:02:36,000 --> 00:02:41,000
|
| 111 |
+
The aspect style was introduced by aspect project.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:02:41,000 --> 00:02:49,000
|
| 115 |
+
Spring interprets the same annotations as aspect j using a library supplied by aspect J for Pointcut
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:02:49,000 --> 00:02:51,000
|
| 119 |
+
parsing and matching.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:02:51,000 --> 00:02:57,000
|
| 123 |
+
So I added aspect j runtime and aspect j tools dependencies here.
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:02:58,000 --> 00:03:00,000
|
| 127 |
+
Just for logging purposes.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:03:00,000 --> 00:03:08,000
|
| 131 |
+
I also added self for G and log back, but this is optional in case you don't need and don't want to
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:03:08,000 --> 00:03:09,000
|
| 135 |
+
configure login.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:03:09,000 --> 00:03:11,000
|
| 139 |
+
This is not necessary.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:03:11,000 --> 00:03:18,000
|
| 143 |
+
The main thing for the sake of today's demo is to add these aspect dependencies.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:03:18,000 --> 00:03:21,000
|
| 147 |
+
Let's now review our business object.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:03:21,000 --> 00:03:25,000
|
| 151 |
+
In our today's example, we are going to deal with the user class.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:03:25,000 --> 00:03:31,000
|
| 155 |
+
All examples related to today's lesson will be located in the AOP package here.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:03:31,000 --> 00:03:37,000
|
| 159 |
+
Nothing is extraordinary, just properties like first name and last name.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:03:37,000 --> 00:03:44,000
|
| 163 |
+
I also preconfigured default first name and last name just for the sake of example getters and setters
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:03:44,000 --> 00:03:47,000
|
| 167 |
+
and one message that throws exception.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:03:47,000 --> 00:03:53,000
|
| 171 |
+
This is created for the sake of example in order I can demonstrate different types of advices.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:03:54,000 --> 00:03:56,000
|
| 175 |
+
Now let's create aspect.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:03:57,000 --> 00:04:03,000
|
| 179 |
+
Please make sure you watch the previous lesson because in previous lesson we discussed all the terminologies
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:04:03,000 --> 00:04:05,000
|
| 183 |
+
that I use in this lesson.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:04:05,000 --> 00:04:11,000
|
| 187 |
+
But just to recap aspect is a class that contains advices and point cards.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:04:12,000 --> 00:04:17,000
|
| 191 |
+
I open class that is called demo aspect, as I already mentioned.
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:04:17,000 --> 00:04:21,000
|
| 195 |
+
Actually Spring app can be configured in different ways.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:04:21,000 --> 00:04:24,000
|
| 199 |
+
There are three ways of configuration.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:04:24,000 --> 00:04:29,000
|
| 203 |
+
They are by spring old style DTD based.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:04:29,000 --> 00:04:38,000
|
| 207 |
+
I'm not sure you will use it ever again by aspect annotation style by spring XML configuration style
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:04:39,000 --> 00:04:47,000
|
| 211 |
+
schema based, but the most widely used approach is spring aspect, annotation style, and in this lesson
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:04:47,000 --> 00:04:51,000
|
| 215 |
+
we will use aspect annotations for configuration.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:04:52,000 --> 00:05:00,000
|
| 219 |
+
With the aspect support enabled any been defined in your application context with a class that is aspect
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:05:01,000 --> 00:05:03,000
|
| 223 |
+
aspect has the aspect annotation.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:05:03,000 --> 00:05:12,000
|
| 227 |
+
Mean will be automatically detected by spring and used to configure spring AOP taking into account the
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:05:12,000 --> 00:05:14,000
|
| 231 |
+
use annotation based configuration.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:05:14,000 --> 00:05:22,000
|
| 235 |
+
I also added component annotation in order inversion of control container create been of such type.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:05:23,000 --> 00:05:29,000
|
| 239 |
+
If you use XML based configuration, then you need to register your bean in XML.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:05:29,000 --> 00:05:36,000
|
| 243 |
+
Having just aspect annotation is not enough for auto detection in the classpath, you need to register
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:05:36,000 --> 00:05:39,000
|
| 247 |
+
it as a spring bean for proper configuration.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:05:40,000 --> 00:05:41,000
|
| 251 |
+
Aspects.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:05:41,000 --> 00:05:47,000
|
| 255 |
+
Classes annotated with aspect may have masses and fields just like any other class.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:05:47,000 --> 00:05:54,000
|
| 259 |
+
They may also contain point, card advice and introduction inter-type declarations.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:05:55,000 --> 00:06:03,000
|
| 263 |
+
Another interesting and important question Can you advise on aspects with other aspects in spring AOP?
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:06:03,000 --> 00:06:09,000
|
| 267 |
+
It is not possible to have aspects themselves be the target of advice from other aspects.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:06:10,000 --> 00:06:18,000
|
| 271 |
+
The aspect annotation on a class marks it as an aspect and hence excludes it from autoproxy.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:06:18,000 --> 00:06:21,000
|
| 275 |
+
So we declare it aspect.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:06:21,000 --> 00:06:22,000
|
| 279 |
+
Put annotation.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:06:22,000 --> 00:06:23,000
|
| 283 |
+
All good.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:06:23,000 --> 00:06:25,000
|
| 287 |
+
What's next?
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:06:25,000 --> 00:06:29,000
|
| 291 |
+
The next thing let's declare a different point class.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:06:29,000 --> 00:06:38,000
|
| 295 |
+
Just to remind you that point cards determine joint points of interest and thus enable us to control
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:06:38,000 --> 00:06:40,000
|
| 299 |
+
when advice executes.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:06:40,000 --> 00:06:44,000
|
| 303 |
+
Spring AOP only supports method execution.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:06:44,000 --> 00:06:52,000
|
| 307 |
+
Join points for spring beans so you can think of a pointcut as matching the execution of methods on
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:06:52,000 --> 00:06:53,000
|
| 311 |
+
spring beans.
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:06:54,000 --> 00:06:56,000
|
| 315 |
+
A Pointcut declaration has two parts.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:06:57,000 --> 00:07:05,000
|
| 319 |
+
A signature comprising a name and any parameters and the pointcut expressions that determines exactly
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:07:05,000 --> 00:07:08,000
|
| 323 |
+
which message executions were interested in.
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:07:08,000 --> 00:07:16,000
|
| 327 |
+
In the aspect annotation style of AOP, a Pointcut signatures provided by a regular method definition
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:07:16,000 --> 00:07:22,000
|
| 331 |
+
and the Pointcut expression is indicated using the Pointcut annotation.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:07:22,000 --> 00:07:27,000
|
| 335 |
+
The method seven as a Pointcut signature must have a void return type.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:07:28,000 --> 00:07:29,000
|
| 339 |
+
Pay attention to this.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:07:30,000 --> 00:07:33,000
|
| 343 |
+
Let's review the first and the most simple example.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:07:34,000 --> 00:07:42,000
|
| 347 |
+
The point card named Select all will match the execution of any message in the current package, namely
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:07:42,000 --> 00:07:45,000
|
| 351 |
+
package with our examples.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:07:45,000 --> 00:07:46,000
|
| 355 |
+
Is it clear?
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:07:46,000 --> 00:07:53,000
|
| 359 |
+
So here we specified execution as it is obviously related directly to the method execution.
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:07:53,000 --> 00:07:55,000
|
| 363 |
+
What else we can specify here?
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:07:56,000 --> 00:08:01,000
|
| 367 |
+
Aspect G provides a lot of different pointcut designators.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:08:01,000 --> 00:08:08,000
|
| 371 |
+
Unfortunately or fortunately, not all of them are supported by spring aspect oriented programming.
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:08:08,000 --> 00:08:15,000
|
| 375 |
+
On this slide you can see only those pointcut designators that are supported by spring AOP.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:08:16,000 --> 00:08:18,000
|
| 379 |
+
Let's review them.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:08:18,000 --> 00:08:23,000
|
| 383 |
+
Execution for matching method execution join points.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:08:23,000 --> 00:08:28,000
|
| 387 |
+
This is probably the most popular pointcut designator when working with spring AOP.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:08:29,000 --> 00:08:38,000
|
| 391 |
+
Within this one limits matching the join points within certain types simply as execution of master declared
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:08:38,000 --> 00:08:40,000
|
| 395 |
+
within a matching type when using spring AOP.
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:08:41,000 --> 00:08:45,000
|
| 399 |
+
This limits matching to join points.
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:08:45,000 --> 00:08:48,000
|
| 403 |
+
The execution of matches when using spring AOP.
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:08:49,000 --> 00:08:54,000
|
| 407 |
+
Whereas a reference spring AOP proxy is an instance of the given type.
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:08:55,000 --> 00:08:57,000
|
| 411 |
+
And the rest are on the slide.
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:08:58,000 --> 00:09:01,000
|
| 415 |
+
I believe there is no need to be reading out loud.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:09:01,000 --> 00:09:09,000
|
| 419 |
+
Each one just press on, pause the video and read through the slide and remember that in case you have
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:09:09,000 --> 00:09:16,000
|
| 423 |
+
any questions, you are always welcome to post your questions below the video and I will be happy to
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:09:16,000 --> 00:09:17,000
|
| 427 |
+
answer.
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:09:17,000 --> 00:09:23,000
|
| 431 |
+
Because Spring AOP limits matching to only method execution join points.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:09:23,000 --> 00:09:31,000
|
| 435 |
+
The discussion of the Pointcut designators gives a narrower definition than you will find in the aspect
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:09:31,000 --> 00:09:33,000
|
| 439 |
+
programming guide.
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:09:33,000 --> 00:09:41,000
|
| 443 |
+
The full aspect Pointcut language supports additional Pointcut designators that are not supported in
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:09:41,000 --> 00:09:41,000
|
| 447 |
+
spring.
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:09:42,000 --> 00:09:46,000
|
| 451 |
+
So once you look through the slide, we are good to continue.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:09:48,000 --> 00:09:52,000
|
| 455 |
+
On this slide, you are going to see different examples of point cuts.
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:09:52,000 --> 00:10:00,000
|
| 459 |
+
For example, the execution of any public method is execution of any method with the name beginning
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:10:00,000 --> 00:10:01,000
|
| 463 |
+
with set.
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:10:01,000 --> 00:10:08,000
|
| 467 |
+
The execution of any method defined by the account service interface and so on.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:10:09,000 --> 00:10:17,000
|
| 471 |
+
Again, I would ask you to put the video on pause and look through the slide at your own pace, taking
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:10:17,000 --> 00:10:20,000
|
| 475 |
+
into account the different variety of combinations.
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:10:20,000 --> 00:10:25,000
|
| 479 |
+
I tried to specify different examples to highlight different cases.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:10:25,000 --> 00:10:32,000
|
| 483 |
+
I'm sure you will find these examples useful when you will need to come up with your own expression
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:10:32,000 --> 00:10:33,000
|
| 487 |
+
at work.
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:10:33,000 --> 00:10:39,000
|
| 491 |
+
Once you looked through the examples, you're welcome to press play button to continue.
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:10:40,000 --> 00:10:47,000
|
| 495 |
+
That was a lot of examples and I'm sure they are super helpful because next time when you will think
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:10:47,000 --> 00:10:54,000
|
| 499 |
+
about creation of the point card, you can just check these examples and create them according to the
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:10:54,000 --> 00:10:55,000
|
| 503 |
+
pattern.
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:10:56,000 --> 00:11:00,000
|
| 507 |
+
So you saw examples of the point cards on the slide.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:11:00,000 --> 00:11:05,000
|
| 511 |
+
I believe you have understanding what it is and how to declare a point cut.
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:11:05,000 --> 00:11:11,000
|
| 515 |
+
Now, I want to you understand the mechanics and how to use point cut in the application.
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:11:12,000 --> 00:11:18,000
|
| 519 |
+
I believe there is no need for me to create all possible combinations of point cuts because we reviewed
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:11:18,000 --> 00:11:21,000
|
| 523 |
+
different examples already on the slides.
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:11:21,000 --> 00:11:27,000
|
| 527 |
+
So here in the application I'm going to have two point cuts, ones that we have already created.
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:11:27,000 --> 00:11:32,000
|
| 531 |
+
It is for all masses execution from the current package.
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:11:32,000 --> 00:11:40,000
|
| 535 |
+
And here's one more like you have seen already on the example, this type of point cut designators that
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:11:40,000 --> 00:11:42,000
|
| 539 |
+
can be used only in spring AOP.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:11:43,000 --> 00:11:46,000
|
| 543 |
+
It is designator called beam.
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:11:46,000 --> 00:11:51,000
|
| 547 |
+
You can limit the matching of join points to a particular spring bin.
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:11:51,000 --> 00:11:56,000
|
| 551 |
+
Here on the screen you can see how I created user bin point cut.
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:11:56,000 --> 00:12:01,000
|
| 555 |
+
You can see a right bin and name of my bin user.
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:12:01,000 --> 00:12:04,000
|
| 559 |
+
I'm going to show you advice demo with this point.
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:12:04,000 --> 00:12:05,000
|
| 563 |
+
Cut to.
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:12:06,000 --> 00:12:07,000
|
| 567 |
+
Amazing.
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:12:07,000 --> 00:12:14,000
|
| 571 |
+
Now we reviewed how to declare a pointcut and what syntax we can use to declare a pointcut.
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:12:14,000 --> 00:12:17,000
|
| 575 |
+
Now it is time to learn how to declare advices.
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:12:17,000 --> 00:12:20,000
|
| 579 |
+
As you remember, we have five types of advices.
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:12:20,000 --> 00:12:22,000
|
| 583 |
+
Let's remember them.
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:12:22,000 --> 00:12:25,000
|
| 587 |
+
We learned them in our previous theoretical lesson.
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:12:25,000 --> 00:12:36,000
|
| 591 |
+
They are before advice, after returning, advice after throwing advice after finally advice and round
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:12:36,000 --> 00:12:36,000
|
| 595 |
+
advice.
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:12:37,000 --> 00:12:40,000
|
| 599 |
+
Let's configure advices of each type here.
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:12:40,000 --> 00:12:42,000
|
| 603 |
+
Let's go one by one.
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:12:43,000 --> 00:12:45,000
|
| 607 |
+
Before advice.
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:12:45,000 --> 00:12:53,000
|
| 611 |
+
Advice that executes before a join point, but which doesn't have the ability to prevent execution flow
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:12:53,000 --> 00:12:58,000
|
| 615 |
+
proceeding to the join point unless it throws an exception.
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:12:59,000 --> 00:13:03,000
|
| 619 |
+
You can see that I declared before advice for the select all point cut.
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:13:03,000 --> 00:13:11,000
|
| 623 |
+
So this code will be applied, whereas the point cut expression from the select all point cut will match.
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:13:11,000 --> 00:13:13,000
|
| 627 |
+
Is that clear?
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:13:13,000 --> 00:13:16,000
|
| 631 |
+
And also for the sake of the demo I created.
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:13:16,000 --> 00:13:23,000
|
| 635 |
+
One more advice for the user being point cut just to show you that everything will work as expected
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:13:23,000 --> 00:13:25,000
|
| 639 |
+
for another point, cut to.
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:13:26,000 --> 00:13:30,000
|
| 643 |
+
The next advice here is after returning advice.
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:13:30,000 --> 00:13:36,000
|
| 647 |
+
After returning the device to be executed after join point completes normally.
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:13:37,000 --> 00:13:44,000
|
| 651 |
+
For example, if a message returns without throwing an exception in case we want to get access to the
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:13:44,000 --> 00:13:50,000
|
| 655 |
+
returned value and work with it, somehow you just declare, return an attribute and declare a message
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:13:50,000 --> 00:13:51,000
|
| 659 |
+
parameter.
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:13:52,000 --> 00:13:56,000
|
| 663 |
+
Return value will be injected into this local variable.
|
| 664 |
+
|
| 665 |
+
167
|
| 666 |
+
00:13:56,000 --> 00:14:02,000
|
| 667 |
+
In our particular case, I would just print it to console to show you how it works.
|
| 668 |
+
|
| 669 |
+
168
|
| 670 |
+
00:14:03,000 --> 00:14:10,000
|
| 671 |
+
I believe that it is clear and sounds logical that the name used in the return attribute must correspond
|
| 672 |
+
|
| 673 |
+
169
|
| 674 |
+
00:14:10,000 --> 00:14:13,000
|
| 675 |
+
to the name of a parameter in the advice method.
|
| 676 |
+
|
| 677 |
+
170
|
| 678 |
+
00:14:15,000 --> 00:14:22,000
|
| 679 |
+
And returning clause also restricts matching to only those method executions that return a value of
|
| 680 |
+
|
| 681 |
+
171
|
| 682 |
+
00:14:22,000 --> 00:14:28,000
|
| 683 |
+
the specified type object in this case, which will match any return value.
|
| 684 |
+
|
| 685 |
+
172
|
| 686 |
+
00:14:29,000 --> 00:14:35,000
|
| 687 |
+
Please note that it is not possible to return a totally different reference when using after returning
|
| 688 |
+
|
| 689 |
+
173
|
| 690 |
+
00:14:35,000 --> 00:14:36,000
|
| 691 |
+
advice.
|
| 692 |
+
|
| 693 |
+
174
|
| 694 |
+
00:14:36,000 --> 00:14:38,000
|
| 695 |
+
Okay, let's move on.
|
| 696 |
+
|
| 697 |
+
175
|
| 698 |
+
00:14:39,000 --> 00:14:48,000
|
| 699 |
+
After throwing advice, this advice to be executed if a method exits by throwing an exception in the
|
| 700 |
+
|
| 701 |
+
176
|
| 702 |
+
00:14:48,000 --> 00:14:49,000
|
| 703 |
+
similar way.
|
| 704 |
+
|
| 705 |
+
177
|
| 706 |
+
00:14:49,000 --> 00:14:54,000
|
| 707 |
+
In case you want to get access to the exception thrown, you need to declare this in the annotation
|
| 708 |
+
|
| 709 |
+
178
|
| 710 |
+
00:14:54,000 --> 00:15:02,000
|
| 711 |
+
configuration where throwing attribute and declare a method parameter with the same name as thrown clause
|
| 712 |
+
|
| 713 |
+
179
|
| 714 |
+
00:15:02,000 --> 00:15:10,000
|
| 715 |
+
also restricts matching to only those method executions that throw an exception of the specified type.
|
| 716 |
+
|
| 717 |
+
180
|
| 718 |
+
00:15:11,000 --> 00:15:13,000
|
| 719 |
+
Exception in our specific case.
|
| 720 |
+
|
| 721 |
+
181
|
| 722 |
+
00:15:14,000 --> 00:15:19,000
|
| 723 |
+
The next type of advice is after finally advice.
|
| 724 |
+
|
| 725 |
+
182
|
| 726 |
+
00:15:20,000 --> 00:15:28,000
|
| 727 |
+
After finally advice to be executed regardless of the means by which a join point exits normal or exceptional
|
| 728 |
+
|
| 729 |
+
183
|
| 730 |
+
00:15:28,000 --> 00:15:35,000
|
| 731 |
+
return, we are going just to print text into the console in order to indicate that this advice has
|
| 732 |
+
|
| 733 |
+
184
|
| 734 |
+
00:15:35,000 --> 00:15:36,000
|
| 735 |
+
been executed.
|
| 736 |
+
|
| 737 |
+
185
|
| 738 |
+
00:15:37,000 --> 00:15:43,000
|
| 739 |
+
And the last but not the least advice type example here is around advice.
|
| 740 |
+
|
| 741 |
+
186
|
| 742 |
+
00:15:43,000 --> 00:15:49,000
|
| 743 |
+
Around advice surrounds a joint point such as method invocation.
|
| 744 |
+
|
| 745 |
+
187
|
| 746 |
+
00:15:49,000 --> 00:15:53,000
|
| 747 |
+
This is the most powerful kind of advice around.
|
| 748 |
+
|
| 749 |
+
188
|
| 750 |
+
00:15:53,000 --> 00:15:58,000
|
| 751 |
+
Advice can perform custom behavior before and after the method invocation.
|
| 752 |
+
|
| 753 |
+
189
|
| 754 |
+
00:15:58,000 --> 00:16:05,000
|
| 755 |
+
It is also responsible for choosing whether to proceed to the join point or to shortcut the advice method
|
| 756 |
+
|
| 757 |
+
190
|
| 758 |
+
00:16:05,000 --> 00:16:10,000
|
| 759 |
+
execution by returning its own return value or throwing an exception.
|
| 760 |
+
|
| 761 |
+
191
|
| 762 |
+
00:16:11,000 --> 00:16:18,000
|
| 763 |
+
So when it is recommended to use around advice, around advice is often used if you need to share state
|
| 764 |
+
|
| 765 |
+
192
|
| 766 |
+
00:16:18,000 --> 00:16:27,000
|
| 767 |
+
before and after method execution in a thread safe manner, starting and stopping a timer, for example,
|
| 768 |
+
|
| 769 |
+
193
|
| 770 |
+
00:16:27,000 --> 00:16:33,000
|
| 771 |
+
always use the least powerful form of advice that meets your requirements.
|
| 772 |
+
|
| 773 |
+
194
|
| 774 |
+
00:16:33,000 --> 00:16:41,000
|
| 775 |
+
That means that it is not recommended to use a rounded voice if simple before advice is enough for your
|
| 776 |
+
|
| 777 |
+
195
|
| 778 |
+
00:16:41,000 --> 00:16:42,000
|
| 779 |
+
specific case.
|
| 780 |
+
|
| 781 |
+
196
|
| 782 |
+
00:16:43,000 --> 00:16:46,000
|
| 783 |
+
A rounded voice is declared using the round annotation.
|
| 784 |
+
|
| 785 |
+
197
|
| 786 |
+
00:16:47,000 --> 00:16:52,000
|
| 787 |
+
The first parameter of the advice method must be of type preceding joint point.
|
| 788 |
+
|
| 789 |
+
198
|
| 790 |
+
00:16:53,000 --> 00:17:00,000
|
| 791 |
+
Within the body of that voice, colon precede on the preceding joint point causes the underlying method
|
| 792 |
+
|
| 793 |
+
199
|
| 794 |
+
00:17:00,000 --> 00:17:02,000
|
| 795 |
+
to execute.
|
| 796 |
+
|
| 797 |
+
200
|
| 798 |
+
00:17:02,000 --> 00:17:07,000
|
| 799 |
+
The proceed mascot may also be called passing in an object array.
|
| 800 |
+
|
| 801 |
+
201
|
| 802 |
+
00:17:07,000 --> 00:17:13,000
|
| 803 |
+
The values in the array will be used as the arguments to the method execution when it proceeds.
|
| 804 |
+
|
| 805 |
+
202
|
| 806 |
+
00:17:14,000 --> 00:17:20,000
|
| 807 |
+
Pay attention that I'm responsible for method invocation and returning the returned value of the method.
|
| 808 |
+
|
| 809 |
+
203
|
| 810 |
+
00:17:21,000 --> 00:17:23,000
|
| 811 |
+
Also potential is invoked.
|
| 812 |
+
|
| 813 |
+
204
|
| 814 |
+
00:17:23,000 --> 00:17:25,000
|
| 815 |
+
Method may throw exception.
|
| 816 |
+
|
| 817 |
+
205
|
| 818 |
+
00:17:25,000 --> 00:17:31,000
|
| 819 |
+
That's why we need either to declare a throws declaration or to handle the potential exception.
|
| 820 |
+
|
| 821 |
+
206
|
| 822 |
+
00:17:32,000 --> 00:17:40,000
|
| 823 |
+
For the sake of the demo, I will print console output before calling the method from advice and after
|
| 824 |
+
|
| 825 |
+
207
|
| 826 |
+
00:17:40,000 --> 00:17:42,000
|
| 827 |
+
we called method from advice.
|
| 828 |
+
|
| 829 |
+
208
|
| 830 |
+
00:17:43,000 --> 00:17:44,000
|
| 831 |
+
That's it.
|
| 832 |
+
|
| 833 |
+
209
|
| 834 |
+
00:17:44,000 --> 00:17:46,000
|
| 835 |
+
We're getting configuration of advices.
|
| 836 |
+
|
| 837 |
+
210
|
| 838 |
+
00:17:46,000 --> 00:17:51,000
|
| 839 |
+
Just one minor thing to do and we are ready for running our application.
|
| 840 |
+
|
| 841 |
+
211
|
| 842 |
+
00:17:51,000 --> 00:17:56,000
|
| 843 |
+
Another important point is to enable aspect support.
|
| 844 |
+
|
| 845 |
+
212
|
| 846 |
+
00:17:57,000 --> 00:17:58,000
|
| 847 |
+
The use aspect.
|
| 848 |
+
|
| 849 |
+
213
|
| 850 |
+
00:17:58,000 --> 00:18:06,000
|
| 851 |
+
Aspects In a spring configuration you need to enable spring support for configuring spring AOP based
|
| 852 |
+
|
| 853 |
+
214
|
| 854 |
+
00:18:06,000 --> 00:18:16,000
|
| 855 |
+
on aspect aspects and auto production beans based on whether or not they are advised by those aspects.
|
| 856 |
+
|
| 857 |
+
215
|
| 858 |
+
00:18:16,000 --> 00:18:25,000
|
| 859 |
+
By auto proxy, I mean that if spring determines that a bean is advised by one or more aspects, it
|
| 860 |
+
|
| 861 |
+
216
|
| 862 |
+
00:18:25,000 --> 00:18:33,000
|
| 863 |
+
will automatically generate a proxy for that bean to intercept method invocations and ensure that advice
|
| 864 |
+
|
| 865 |
+
217
|
| 866 |
+
00:18:33,000 --> 00:18:35,000
|
| 867 |
+
is executed as needed.
|
| 868 |
+
|
| 869 |
+
218
|
| 870 |
+
00:18:35,000 --> 00:18:41,000
|
| 871 |
+
You can enable it with an XML configuration or with a special annotation.
|
| 872 |
+
|
| 873 |
+
219
|
| 874 |
+
00:18:41,000 --> 00:18:42,000
|
| 875 |
+
Let me show it to you.
|
| 876 |
+
|
| 877 |
+
220
|
| 878 |
+
00:18:43,000 --> 00:18:51,000
|
| 879 |
+
Here I have demo a class where I have main method to demo all the examples that we have reviewed, but
|
| 880 |
+
|
| 881 |
+
221
|
| 882 |
+
00:18:51,000 --> 00:18:54,000
|
| 883 |
+
also this class serves as a configuration.
|
| 884 |
+
|
| 885 |
+
222
|
| 886 |
+
00:18:54,000 --> 00:18:59,000
|
| 887 |
+
You can see that I added enable aspect auto proxy annotation.
|
| 888 |
+
|
| 889 |
+
223
|
| 890 |
+
00:18:59,000 --> 00:19:08,000
|
| 891 |
+
That's enough in order to make spring auto detect aspect annotations and configuration and to make proxies
|
| 892 |
+
|
| 893 |
+
224
|
| 894 |
+
00:19:08,000 --> 00:19:11,000
|
| 895 |
+
when needed to intercept method invocations.
|
| 896 |
+
|
| 897 |
+
225
|
| 898 |
+
00:19:12,000 --> 00:19:16,000
|
| 899 |
+
And now we are completely fine to run our example.
|
| 900 |
+
|
| 901 |
+
226
|
| 902 |
+
00:19:16,000 --> 00:19:18,000
|
| 903 |
+
Let's take a look at main method.
|
| 904 |
+
|
| 905 |
+
227
|
| 906 |
+
00:19:19,000 --> 00:19:22,000
|
| 907 |
+
I create annotation config application context.
|
| 908 |
+
|
| 909 |
+
228
|
| 910 |
+
00:19:23,000 --> 00:19:26,000
|
| 911 |
+
I scan package with our ALP examples.
|
| 912 |
+
|
| 913 |
+
229
|
| 914 |
+
00:19:26,000 --> 00:19:35,000
|
| 915 |
+
I extract user bin and in order to show you all type of advices I am going to invoke method that doesn't
|
| 916 |
+
|
| 917 |
+
230
|
| 918 |
+
00:19:35,000 --> 00:19:36,000
|
| 919 |
+
throw any exception.
|
| 920 |
+
|
| 921 |
+
231
|
| 922 |
+
00:19:36,000 --> 00:19:44,000
|
| 923 |
+
And then I will call one method that deliberately throws exception in order to demo you all kind of
|
| 924 |
+
|
| 925 |
+
232
|
| 926 |
+
00:19:44,000 --> 00:19:45,000
|
| 927 |
+
advices configure it.
|
| 928 |
+
|
| 929 |
+
233
|
| 930 |
+
00:19:46,000 --> 00:19:47,000
|
| 931 |
+
That's it.
|
| 932 |
+
|
| 933 |
+
234
|
| 934 |
+
00:19:47,000 --> 00:19:52,000
|
| 935 |
+
Let me run the program and explore the console output together with you.
|
| 936 |
+
|
| 937 |
+
235
|
| 938 |
+
00:19:53,000 --> 00:19:58,000
|
| 939 |
+
At the beginning you can see that we entered rounded voice before calling method.
|
| 940 |
+
|
| 941 |
+
236
|
| 942 |
+
00:19:59,000 --> 00:20:02,000
|
| 943 |
+
After that we have to before advices.
|
| 944 |
+
|
| 945 |
+
237
|
| 946 |
+
00:20:02,000 --> 00:20:09,000
|
| 947 |
+
If you remember, we created before advice for select all pointcut and one before advice for the user
|
| 948 |
+
|
| 949 |
+
238
|
| 950 |
+
00:20:09,000 --> 00:20:10,000
|
| 951 |
+
being pointcut.
|
| 952 |
+
|
| 953 |
+
239
|
| 954 |
+
00:20:11,000 --> 00:20:18,000
|
| 955 |
+
Then we have after returning advice and we print returned values that we got inside the advice.
|
| 956 |
+
|
| 957 |
+
240
|
| 958 |
+
00:20:18,000 --> 00:20:22,000
|
| 959 |
+
Here is the first name of configure it user bin.
|
| 960 |
+
|
| 961 |
+
241
|
| 962 |
+
00:20:22,000 --> 00:20:26,000
|
| 963 |
+
After that, after finally advice worked.
|
| 964 |
+
|
| 965 |
+
242
|
| 966 |
+
00:20:26,000 --> 00:20:32,000
|
| 967 |
+
And only after that we can say that we are about to leave our around advice.
|
| 968 |
+
|
| 969 |
+
243
|
| 970 |
+
00:20:32,000 --> 00:20:37,000
|
| 971 |
+
That's why we can see console output from around advice here.
|
| 972 |
+
|
| 973 |
+
244
|
| 974 |
+
00:20:38,000 --> 00:20:42,000
|
| 975 |
+
Then I actually print returned first name to console.
|
| 976 |
+
|
| 977 |
+
245
|
| 978 |
+
00:20:42,000 --> 00:20:43,000
|
| 979 |
+
That's it.
|
| 980 |
+
|
| 981 |
+
246
|
| 982 |
+
00:20:44,000 --> 00:20:50,000
|
| 983 |
+
Now we have the second method demo in the similar way you can see first console output from the round
|
| 984 |
+
|
| 985 |
+
247
|
| 986 |
+
00:20:50,000 --> 00:20:55,000
|
| 987 |
+
advice and then we see console output from two before advices.
|
| 988 |
+
|
| 989 |
+
248
|
| 990 |
+
00:20:56,000 --> 00:21:04,000
|
| 991 |
+
Then we don't see after returning advice because method didn't finish execution properly and exception
|
| 992 |
+
|
| 993 |
+
249
|
| 994 |
+
00:21:04,000 --> 00:21:05,000
|
| 995 |
+
was thrown.
|
| 996 |
+
|
| 997 |
+
250
|
| 998 |
+
00:21:06,000 --> 00:21:10,000
|
| 999 |
+
I see the console output from the method that exception has been thrown.
|
| 1000 |
+
|
| 1001 |
+
251
|
| 1002 |
+
00:21:10,000 --> 00:21:18,000
|
| 1003 |
+
Then I entered after throwing advice and I print the class of the exception to console because I got
|
| 1004 |
+
|
| 1005 |
+
252
|
| 1006 |
+
00:21:18,000 --> 00:21:26,000
|
| 1007 |
+
access to it inside the advice and then I see console output from the after finally advice and stack
|
| 1008 |
+
|
| 1009 |
+
253
|
| 1010 |
+
00:21:26,000 --> 00:21:28,000
|
| 1011 |
+
trace of exception.
|
| 1012 |
+
|
| 1013 |
+
254
|
| 1014 |
+
00:21:29,000 --> 00:21:35,000
|
| 1015 |
+
Pay attention that you can't see the last console output from the rounded device because during the
|
| 1016 |
+
|
| 1017 |
+
255
|
| 1018 |
+
00:21:35,000 --> 00:21:38,000
|
| 1019 |
+
method execution exception was thrown.
|
| 1020 |
+
|
| 1021 |
+
256
|
| 1022 |
+
00:21:38,000 --> 00:21:40,000
|
| 1023 |
+
And team please.
|
| 1024 |
+
|
| 1025 |
+
257
|
| 1026 |
+
00:21:40,000 --> 00:21:46,000
|
| 1027 |
+
Even in case something is not clear, let me know and I will be happy to help you.
|
| 1028 |
+
|
| 1029 |
+
258
|
| 1030 |
+
00:21:46,000 --> 00:21:47,000
|
| 1031 |
+
Amazing.
|
| 1032 |
+
|
| 1033 |
+
259
|
| 1034 |
+
00:21:47,000 --> 00:21:48,000
|
| 1035 |
+
That's how it works.
|
| 1036 |
+
|
| 1037 |
+
260
|
| 1038 |
+
00:21:48,000 --> 00:21:51,000
|
| 1039 |
+
And that's all what I wanted to share with you.
|
| 1040 |
+
|
| 1041 |
+
261
|
| 1042 |
+
00:21:51,000 --> 00:21:54,000
|
| 1043 |
+
Let's recap what we have learned today.
|
| 1044 |
+
|
| 1045 |
+
262
|
| 1046 |
+
00:21:55,000 --> 00:21:58,000
|
| 1047 |
+
We learned on practice.
|
| 1048 |
+
|
| 1049 |
+
263
|
| 1050 |
+
00:21:58,000 --> 00:22:03,000
|
| 1051 |
+
Now you know how to create aspect, how to configure pointcuts and advices.
|
| 1052 |
+
|
| 1053 |
+
264
|
| 1054 |
+
00:22:04,000 --> 00:22:07,000
|
| 1055 |
+
We learned different pointcut designators.
|
| 1056 |
+
|
| 1057 |
+
265
|
| 1058 |
+
00:22:07,000 --> 00:22:13,000
|
| 1059 |
+
You saw how to activate spring AOP support of aspect annotations.
|
| 1060 |
+
|
| 1061 |
+
266
|
| 1062 |
+
00:22:13,000 --> 00:22:16,000
|
| 1063 |
+
And we reviewed live code examples.
|
| 1064 |
+
|
| 1065 |
+
267
|
| 1066 |
+
00:22:17,000 --> 00:22:19,000
|
| 1067 |
+
That's all what I wanted to share with you today.
|
| 1068 |
+
|
| 1069 |
+
268
|
| 1070 |
+
00:22:19,000 --> 00:22:21,000
|
| 1071 |
+
Thanks a lot for your attention.
|
| 1072 |
+
|
| 1073 |
+
269
|
| 1074 |
+
00:22:21,000 --> 00:22:24,000
|
| 1075 |
+
Have a great day and see you in the next lesson.
|
| 1076 |
+
|
90 - Spring AOP/external-links.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
002 Source-code-of-examples-commit-with-changes-
|
| 3 |
+
https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/ab0084445a16c0c8897cc80308c28817d9dace8a
|
91 - REST Architecture/001 REST Architecture Overview and Key Principles_en.srt
ADDED
|
@@ -0,0 +1,1012 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:05,000 --> 00:00:06,000
|
| 3 |
+
Hello, team.
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:06,000 --> 00:00:09,000
|
| 7 |
+
Today we start learning interesting and important topic.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:09,000 --> 00:00:12,000
|
| 11 |
+
We're going to learn rest architecture.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:13,000 --> 00:00:19,000
|
| 15 |
+
This is going to be theoretical lesson, but it is important to understand concepts that we are going
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:19,000 --> 00:00:26,000
|
| 19 |
+
to use in the following practical lessons where we are going to learn different ways of how we can implement
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:26,000 --> 00:00:28,000
|
| 23 |
+
rest architecture in the application.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:29,000 --> 00:00:35,000
|
| 27 |
+
We'll start the video from the understanding such definitions as Rest and Rest API.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:36,000 --> 00:00:41,000
|
| 31 |
+
After that, we are going to talk about key principles of rest architectural style.
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:41,000 --> 00:00:45,000
|
| 35 |
+
These principles distinguish rest approach uniquely.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:45,000 --> 00:00:51,000
|
| 39 |
+
Namely, we are going to talk about client server communication, stateless communication caching,
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:51,000 --> 00:00:55,000
|
| 43 |
+
uniform interface, layered system code on demand.
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:56,000 --> 00:01:02,000
|
| 47 |
+
After that, I'm going to explain the concept of the resource in rest and resource methods.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:01:03,000 --> 00:01:09,000
|
| 51 |
+
And at the end of the lesson, I'm going to compare rest with HTTP because a lot of people use these
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:01:09,000 --> 00:01:16,000
|
| 55 |
+
two terms interchangeably, but actually they are different and we are going to understand why.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:01:17,000 --> 00:01:19,000
|
| 59 |
+
Let's start our lesson.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:01:19,000 --> 00:01:21,000
|
| 63 |
+
Let's start with definition.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:01:21,000 --> 00:01:24,000
|
| 67 |
+
So what is rest?
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:01:25,000 --> 00:01:29,000
|
| 71 |
+
Rest stands for representational state transfer.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:01:29,000 --> 00:01:34,000
|
| 75 |
+
It is an architectural style for distributed hypermedia systems.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:01:34,000 --> 00:01:37,000
|
| 79 |
+
It was presented the first time in the 2000.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:01:38,000 --> 00:01:44,000
|
| 83 |
+
It was established with the goal of improving performance, scalability and simplicity by enforcing
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:01:44,000 --> 00:01:47,000
|
| 87 |
+
specific limits on an API.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:01:47,000 --> 00:01:55,000
|
| 91 |
+
It has gained popularity because of the opportunity to cover various devices and applications in rest
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:01:55,000 --> 00:01:56,000
|
| 95 |
+
architecture.
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:01:56,000 --> 00:02:04,000
|
| 99 |
+
A rest server simply provides access to resources and rest client accesses and modifies the resources.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:02:04,000 --> 00:02:05,000
|
| 103 |
+
Here.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:02:05,000 --> 00:02:10,000
|
| 107 |
+
Each resource is identified by Uri's global IDs.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:02:10,000 --> 00:02:17,000
|
| 111 |
+
Rest uses various representation to represent a resource like text JSON.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:02:17,000 --> 00:02:18,000
|
| 115 |
+
XML.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:02:18,000 --> 00:02:20,000
|
| 119 |
+
JSON is the most popular one.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:02:21,000 --> 00:02:26,000
|
| 123 |
+
A web API or API of a web service that is conforming to the rest.
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:02:26,000 --> 00:02:30,000
|
| 127 |
+
Architectural style is called Rest API.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:02:31,000 --> 00:02:38,000
|
| 131 |
+
These Web services utilize a stateless protocol to make textual representations of their online resources
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:02:38,000 --> 00:02:41,000
|
| 135 |
+
available for reading and processing.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:02:42,000 --> 00:02:48,000
|
| 139 |
+
A client performs well known HTTP protocol based activities like Fetch, Update and delete.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:02:49,000 --> 00:02:57,000
|
| 143 |
+
And similar to other architectural styles and patterns, Rest has its own guiding principles and constraints.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:02:57,000 --> 00:03:04,000
|
| 147 |
+
These principles must be satisfied if a service interface needs to be referred as restful.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:03:04,000 --> 00:03:12,000
|
| 151 |
+
Let's now review key rest principles guidelines of how they're also called in other sources.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:03:12,000 --> 00:03:13,000
|
| 155 |
+
Constraints.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:03:13,000 --> 00:03:22,000
|
| 159 |
+
They are client server communication, stateless communication caching Uniform interface layer system
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:03:22,000 --> 00:03:24,000
|
| 163 |
+
code on demand.
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:03:24,000 --> 00:03:26,000
|
| 167 |
+
Let's review them one by one.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:03:27,000 --> 00:03:32,000
|
| 171 |
+
The first rest principle is about client server separation.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:03:32,000 --> 00:03:39,000
|
| 175 |
+
The client server design pattern enforces the separation of concerns, which helps the client and the
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:03:39,000 --> 00:03:42,000
|
| 179 |
+
server components evolve independently.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:03:42,000 --> 00:03:45,000
|
| 183 |
+
What does it mean for the rest architecture?
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:03:45,000 --> 00:03:52,000
|
| 187 |
+
This means that according to rest architectural approach, client and server can be developed independently
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:03:52,000 --> 00:03:54,000
|
| 191 |
+
and don't have to know about each other.
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:03:55,000 --> 00:04:00,000
|
| 195 |
+
The server side shouldn't affect the way how client is implemented.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:04:00,000 --> 00:04:06,000
|
| 199 |
+
The server should just provide the API to send the essential data when requested.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:04:06,000 --> 00:04:09,000
|
| 203 |
+
This also gives us another advantage.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:04:09,000 --> 00:04:16,000
|
| 207 |
+
You can change client without changing the server side and changing the server side shouldn't impact
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:04:16,000 --> 00:04:17,000
|
| 211 |
+
the client side.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:04:18,000 --> 00:04:27,000
|
| 215 |
+
By separating the user interface concerns client from the data storage concerns server side, we improve
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:04:27,000 --> 00:04:33,000
|
| 219 |
+
the portability of the user interface across multiple platforms and improves scalability by simplifying
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:04:33,000 --> 00:04:35,000
|
| 223 |
+
the server components.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:04:36,000 --> 00:04:40,000
|
| 227 |
+
The next rest principle can be called as stateless communication.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:04:40,000 --> 00:04:48,000
|
| 231 |
+
Statelessness mandates that each request from the client to the server must contain all of the information
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:04:48,000 --> 00:04:51,000
|
| 235 |
+
necessary to understand and complete the request.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:04:52,000 --> 00:04:55,000
|
| 239 |
+
Rest based systems are stateless.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:04:55,000 --> 00:05:01,000
|
| 243 |
+
This means that the client state remains unknown to the server and vice versa.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:05:01,000 --> 00:05:09,000
|
| 247 |
+
This constraint allows the server and the client to understand any sent message, even if they haven't
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:05:09,000 --> 00:05:11,000
|
| 251 |
+
seen the preceding ones.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:05:11,000 --> 00:05:18,000
|
| 255 |
+
The server can't take advantage of any previously stored context information on the server.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:05:19,000 --> 00:05:24,000
|
| 259 |
+
For this reason, the session state should be entirely stored on the client side.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:05:25,000 --> 00:05:26,000
|
| 263 |
+
Let's move on.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:05:27,000 --> 00:05:35,000
|
| 267 |
+
Now let's talk about such constraint of rest architecture as caching or like it also called cacheable
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:05:35,000 --> 00:05:36,000
|
| 271 |
+
data.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:05:37,000 --> 00:05:44,000
|
| 275 |
+
The cacheable constraint requires that the response should implicitly or explicitly label itself as
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:05:44,000 --> 00:05:47,000
|
| 279 |
+
cacheable or non-cacheable.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:05:47,000 --> 00:05:54,000
|
| 283 |
+
Data and response caching are critical in today's world because it results in better client side performance.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:05:55,000 --> 00:05:57,000
|
| 287 |
+
Why it is so important.
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:05:57,000 --> 00:06:03,000
|
| 291 |
+
Because caching is one of the ways to improve performance and performance is one of the key goals of
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:06:03,000 --> 00:06:05,000
|
| 295 |
+
rest architecture.
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:06:05,000 --> 00:06:11,000
|
| 299 |
+
Basically, this is logical why you should send new request to fetch the data.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:06:11,000 --> 00:06:17,000
|
| 303 |
+
If it's state not changed and it is cached already on the client side.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:06:17,000 --> 00:06:25,000
|
| 307 |
+
This increases performance if the response is cacheable the client application gets the right to reuse
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:06:25,000 --> 00:06:28,000
|
| 311 |
+
the response data later for equivalent requests.
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:06:29,000 --> 00:06:37,000
|
| 315 |
+
It also gives a server more scalability options due to the smaller burden on the server by using HTTP
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:06:37,000 --> 00:06:45,000
|
| 319 |
+
headers and origin server indicates whether response can be cached and if so, for how long.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:06:45,000 --> 00:06:50,000
|
| 323 |
+
Optimizes the network using cache and improves the overall quality of service.
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:06:50,000 --> 00:06:52,000
|
| 327 |
+
In the following ways.
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:06:52,000 --> 00:06:53,000
|
| 331 |
+
Reduce bandwidth.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:06:53,000 --> 00:06:55,000
|
| 335 |
+
Reduce latency.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:06:55,000 --> 00:06:57,000
|
| 339 |
+
Reduce load on servers.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:06:57,000 --> 00:06:59,000
|
| 343 |
+
Hide network Failures.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:06:59,000 --> 00:07:07,000
|
| 347 |
+
Talking about recommendations, it is worth to mention get requests should be cacheable by default until
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:07:07,000 --> 00:07:10,000
|
| 351 |
+
a special condition arises.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:07:10,000 --> 00:07:14,000
|
| 355 |
+
Usually browsers treat all get requests as cacheable.
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:07:15,000 --> 00:07:23,000
|
| 359 |
+
Post requests are not cacheable by default, but can be made cacheable if is an express header or a
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:07:23,000 --> 00:07:30,000
|
| 363 |
+
cache control header with a directive to explicitly allows, caching is added to the response.
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:07:30,000 --> 00:07:34,000
|
| 367 |
+
Responses to put and delete requests are not cacheable at all.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:07:35,000 --> 00:07:43,000
|
| 371 |
+
The uniform interface constraint that any restful architecture should comply with actually means that,
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:07:43,000 --> 00:07:49,000
|
| 375 |
+
along with the data server responses, should also announce available actions and resources.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:07:50,000 --> 00:07:57,000
|
| 379 |
+
In other words, querying resources should allow the client to request other actions and resources without
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:07:57,000 --> 00:07:59,000
|
| 383 |
+
knowing them in advance.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:07:59,000 --> 00:08:02,000
|
| 387 |
+
Let's look at the example of response.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:08:02,000 --> 00:08:08,000
|
| 391 |
+
You can see it on the slide just by analyzing the single response.
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:08:08,000 --> 00:08:12,000
|
| 395 |
+
A client knows what entities were queried.
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:08:12,000 --> 00:08:14,000
|
| 399 |
+
Articles in this example.
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:08:14,000 --> 00:08:17,000
|
| 403 |
+
How are these entities are structured?
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:08:17,000 --> 00:08:25,000
|
| 407 |
+
Articles have fields ID title author commands how to retrieve related entities.
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:08:25,000 --> 00:08:35,000
|
| 411 |
+
For example, the author and the comments that there are more entities of type articles than based on
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:08:35,000 --> 00:08:38,000
|
| 415 |
+
the current response length and pagination links.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:08:39,000 --> 00:08:47,000
|
| 419 |
+
Using interfaces to decouple classes from the implementation of their dependencies is a pretty old concept
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:08:47,000 --> 00:08:48,000
|
| 423 |
+
in rust.
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:08:48,000 --> 00:08:55,000
|
| 427 |
+
You use the same concept to decouple the client from the implementation of the rest service in order
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:08:55,000 --> 00:09:00,000
|
| 431 |
+
to define such an interface, a contract between the client and the service.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:09:00,000 --> 00:09:02,000
|
| 435 |
+
You have to use standards.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:09:02,000 --> 00:09:10,000
|
| 439 |
+
This is because if you want an internet size network of rest services, you have to enforce global concepts
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:09:10,000 --> 00:09:14,000
|
| 443 |
+
like standards to make them understand each other.
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:09:14,000 --> 00:09:21,000
|
| 447 |
+
By applying the principle of generality to the components interface, we can simplify the overall system
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:09:21,000 --> 00:09:25,000
|
| 451 |
+
architecture and improve the visibility of interactions.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:09:25,000 --> 00:09:32,000
|
| 455 |
+
Multiple architectural constraints help in obtaining a uniform interface and guiding the behavior of
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:09:32,000 --> 00:09:33,000
|
| 459 |
+
components.
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:09:33,000 --> 00:09:38,000
|
| 463 |
+
The following four constraints can achieve a uniform rest interface.
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:09:39,000 --> 00:09:42,000
|
| 467 |
+
The first one an amplification of resources.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:09:42,000 --> 00:09:47,000
|
| 471 |
+
You use the UI standard to identify a resource.
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:09:47,000 --> 00:09:54,000
|
| 475 |
+
The interface must uniquely identify each resource involved in the interaction between the client and
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:09:54,000 --> 00:09:54,000
|
| 479 |
+
the server.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:09:55,000 --> 00:10:01,000
|
| 483 |
+
The second constraint Manipulation of resources through representations.
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:10:01,000 --> 00:10:05,000
|
| 487 |
+
You use the HTTP standard to describe communication.
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:10:05,000 --> 00:10:13,000
|
| 491 |
+
So for example, get means that you want to retrieve data about the UI identified resource.
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:10:13,000 --> 00:10:18,000
|
| 495 |
+
You can describe an operation with an HTTP method and the URI.
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:10:19,000 --> 00:10:23,000
|
| 499 |
+
The third constraint Self-descriptive messages.
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:10:23,000 --> 00:10:30,000
|
| 503 |
+
Each resource representation should carry enough information to describe how to process the message.
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:10:30,000 --> 00:10:37,000
|
| 507 |
+
It should also provide information of the additional actions that the client can perform on the resource.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:10:37,000 --> 00:10:47,000
|
| 511 |
+
You use standard meme types and standard RDF vocabulary to make messages self-descriptive so the client
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:10:47,000 --> 00:10:53,000
|
| 515 |
+
can find the data by checking the semantics and it doesn't have to know the application specific data
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:10:53,000 --> 00:10:54,000
|
| 519 |
+
structure.
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:10:54,000 --> 00:10:56,000
|
| 523 |
+
This service uses.
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:10:57,000 --> 00:11:01,000
|
| 527 |
+
I used here the term RDF vocabulary.
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:11:01,000 --> 00:11:03,000
|
| 531 |
+
Let me explain you what it is.
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:11:04,000 --> 00:11:08,000
|
| 535 |
+
RDF stands for the Resource Description Framework.
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:11:08,000 --> 00:11:15,000
|
| 539 |
+
It is a world wide Web consortium standard originally designed as a data model for metadata.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:11:15,000 --> 00:11:23,000
|
| 543 |
+
It has come to be used as a general method for description and exchange of graph data.
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:11:23,000 --> 00:11:31,000
|
| 547 |
+
RDF provides a variety of syntax, notations and data serialization formats that you potentially may
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:11:31,000 --> 00:11:35,000
|
| 551 |
+
reuse while designing your rest services.
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:11:36,000 --> 00:11:37,000
|
| 555 |
+
Don't worry about formats.
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:11:37,000 --> 00:11:43,000
|
| 559 |
+
We are going to have practical examples and lessons full of practical exercises where we will build
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:11:43,000 --> 00:11:47,000
|
| 563 |
+
our rest services and I will show you how it works.
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:11:47,000 --> 00:11:50,000
|
| 567 |
+
And the force constraint.
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:11:50,000 --> 00:11:59,000
|
| 571 |
+
Hypermedia as the engine of application state, also known as Hateoas, you use hyperlinks and possibly
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:11:59,000 --> 00:12:05,000
|
| 575 |
+
you write templates to decouple the client from the application specific structure.
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:12:05,000 --> 00:12:11,000
|
| 579 |
+
You can annotate these hyperlinks so the client will understand what they mean.
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:12:12,000 --> 00:12:16,000
|
| 583 |
+
The client should have only the initial UI of the application.
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:12:17,000 --> 00:12:25,000
|
| 587 |
+
The client application should dynamically drive all other resources and interactions with use of hyperlinks.
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:12:26,000 --> 00:12:34,000
|
| 591 |
+
Uniform interface Rest Architectural constraint is not the one the easiest to understand, but the one
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:12:34,000 --> 00:12:35,000
|
| 595 |
+
which is also important.
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:12:36,000 --> 00:12:42,000
|
| 599 |
+
Remember that in case you have any questions, you can always ask your questions below the video and
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:12:42,000 --> 00:12:44,000
|
| 603 |
+
I will be happy to answer.
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:12:44,000 --> 00:12:46,000
|
| 607 |
+
Let's continue.
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:12:47,000 --> 00:12:48,000
|
| 611 |
+
The next rest.
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:12:48,000 --> 00:12:51,000
|
| 615 |
+
Architectural constraint is called layered system.
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:12:52,000 --> 00:12:58,000
|
| 619 |
+
If you remember previously in the course we had a lesson that is called layered architecture.
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:12:58,000 --> 00:13:05,000
|
| 623 |
+
It is kind of similar thing that I'm going to explain you now and also in my course, Java from zero
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:13:05,000 --> 00:13:11,000
|
| 627 |
+
to first job together with my students, we implemented online shop according to the layered architecture
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:13:11,000 --> 00:13:13,000
|
| 631 |
+
design pattern.
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:13:13,000 --> 00:13:20,000
|
| 635 |
+
The key concept in the layered system is that each layer has specific function and code is structured
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:13:20,000 --> 00:13:28,000
|
| 639 |
+
accordingly and separated logically between layers according to the rest architectural approach.
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:13:28,000 --> 00:13:36,000
|
| 643 |
+
Layered system term has slightly different shape and form, but the concept is the same to divide responsibilities
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:13:36,000 --> 00:13:41,000
|
| 647 |
+
between modules that are located in different logical layers.
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:13:41,000 --> 00:13:50,000
|
| 651 |
+
If you remember when we learned layered architecture, I highlighted that in layered system, each component
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:13:50,000 --> 00:13:55,000
|
| 655 |
+
can't see beyond the immediate layer they're interacting with.
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:13:56,000 --> 00:14:04,000
|
| 659 |
+
That means that changes in one layer theoretically may impact only the nearest level, but not impacting
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:14:04,000 --> 00:14:06,000
|
| 663 |
+
the whole graph of layers.
|
| 664 |
+
|
| 665 |
+
167
|
| 666 |
+
00:14:07,000 --> 00:14:13,000
|
| 667 |
+
The rest API layers have their responsibilities and come in hierarchical order.
|
| 668 |
+
|
| 669 |
+
168
|
| 670 |
+
00:14:13,000 --> 00:14:18,000
|
| 671 |
+
For example, one layer may be responsible for storing data on the server.
|
| 672 |
+
|
| 673 |
+
169
|
| 674 |
+
00:14:19,000 --> 00:14:26,000
|
| 675 |
+
The second for deploying the APIs on another server and the third for authenticating requests in another
|
| 676 |
+
|
| 677 |
+
170
|
| 678 |
+
00:14:26,000 --> 00:14:27,000
|
| 679 |
+
server.
|
| 680 |
+
|
| 681 |
+
171
|
| 682 |
+
00:14:27,000 --> 00:14:34,000
|
| 683 |
+
All layers act as mediators between the client and applications deployed on the server side.
|
| 684 |
+
|
| 685 |
+
172
|
| 686 |
+
00:14:35,000 --> 00:14:43,000
|
| 687 |
+
In this way we prevent direct interaction between the client and server side applications and as a result,
|
| 688 |
+
|
| 689 |
+
173
|
| 690 |
+
00:14:43,000 --> 00:14:46,000
|
| 691 |
+
a client doesn't know which server.
|
| 692 |
+
|
| 693 |
+
174
|
| 694 |
+
00:14:46,000 --> 00:14:48,000
|
| 695 |
+
A component is a address.
|
| 696 |
+
|
| 697 |
+
175
|
| 698 |
+
00:14:48,000 --> 00:14:54,000
|
| 699 |
+
And the most important thing they don't want to know and don't need to know.
|
| 700 |
+
|
| 701 |
+
176
|
| 702 |
+
00:14:55,000 --> 00:15:01,000
|
| 703 |
+
This gives us different advantages, namely, it improves the APIs overall security.
|
| 704 |
+
|
| 705 |
+
177
|
| 706 |
+
00:15:02,000 --> 00:15:11,000
|
| 707 |
+
Also, it improves flexibility because adding altering or removing APIs on other levels shouldn't impact
|
| 708 |
+
|
| 709 |
+
178
|
| 710 |
+
00:15:11,000 --> 00:15:16,000
|
| 711 |
+
the key components that are in charge of interaction with client.
|
| 712 |
+
|
| 713 |
+
179
|
| 714 |
+
00:15:17,000 --> 00:15:20,000
|
| 715 |
+
The next constraint is called code on demand.
|
| 716 |
+
|
| 717 |
+
180
|
| 718 |
+
00:15:21,000 --> 00:15:29,000
|
| 719 |
+
Rest also allows client functionality to extend by downloading and executing code in the form of applets
|
| 720 |
+
|
| 721 |
+
181
|
| 722 |
+
00:15:29,000 --> 00:15:30,000
|
| 723 |
+
or scripts.
|
| 724 |
+
|
| 725 |
+
182
|
| 726 |
+
00:15:31,000 --> 00:15:39,000
|
| 727 |
+
The downloaded code simplifies clients by reducing the number of features required to be implemented.
|
| 728 |
+
|
| 729 |
+
183
|
| 730 |
+
00:15:39,000 --> 00:15:46,000
|
| 731 |
+
Servers can provide part of features delivered to the client in the form of code, and the client only
|
| 732 |
+
|
| 733 |
+
184
|
| 734 |
+
00:15:46,000 --> 00:15:48,000
|
| 735 |
+
needs to execute the code.
|
| 736 |
+
|
| 737 |
+
185
|
| 738 |
+
00:15:48,000 --> 00:15:56,000
|
| 739 |
+
Rest Architectural style allows users to download and run code in the form of Java applets or scripts
|
| 740 |
+
|
| 741 |
+
186
|
| 742 |
+
00:15:56,000 --> 00:15:58,000
|
| 743 |
+
such as JavaScript.
|
| 744 |
+
|
| 745 |
+
187
|
| 746 |
+
00:15:58,000 --> 00:16:05,000
|
| 747 |
+
I wouldn't say that Java applets are popular and working nowadays at all, but with regard to JavaScript,
|
| 748 |
+
|
| 749 |
+
188
|
| 750 |
+
00:16:05,000 --> 00:16:07,000
|
| 751 |
+
this can be relevant.
|
| 752 |
+
|
| 753 |
+
189
|
| 754 |
+
00:16:07,000 --> 00:16:14,000
|
| 755 |
+
For example, clients can retrieve the rendering code for UI widgets by calling your API.
|
| 756 |
+
|
| 757 |
+
190
|
| 758 |
+
00:16:15,000 --> 00:16:22,000
|
| 759 |
+
But still, the most common scenario of using rest APIs is to deliver static resource representations
|
| 760 |
+
|
| 761 |
+
191
|
| 762 |
+
00:16:22,000 --> 00:16:24,000
|
| 763 |
+
in XML or JSON.
|
| 764 |
+
|
| 765 |
+
192
|
| 766 |
+
00:16:25,000 --> 00:16:31,000
|
| 767 |
+
It also worth to mention that the key concept in the rest architecture is the concept of resource.
|
| 768 |
+
|
| 769 |
+
193
|
| 770 |
+
00:16:31,000 --> 00:16:36,000
|
| 771 |
+
The key abstraction of information in rest is a resource.
|
| 772 |
+
|
| 773 |
+
194
|
| 774 |
+
00:16:36,000 --> 00:16:39,000
|
| 775 |
+
An information that we can name can be a resource.
|
| 776 |
+
|
| 777 |
+
195
|
| 778 |
+
00:16:40,000 --> 00:16:47,000
|
| 779 |
+
For example, a rest resource can be a document or image, a temporal service, a collection of other
|
| 780 |
+
|
| 781 |
+
196
|
| 782 |
+
00:16:47,000 --> 00:16:48,000
|
| 783 |
+
resources.
|
| 784 |
+
|
| 785 |
+
197
|
| 786 |
+
00:16:49,000 --> 00:16:54,000
|
| 787 |
+
A rest API consists of an assembly of interlinked resources.
|
| 788 |
+
|
| 789 |
+
198
|
| 790 |
+
00:16:55,000 --> 00:17:00,000
|
| 791 |
+
This set of resources is known as the Rest APIs Resource model.
|
| 792 |
+
|
| 793 |
+
199
|
| 794 |
+
00:17:01,000 --> 00:17:07,000
|
| 795 |
+
Another important thing to understand in the rest terminology is resource masses.
|
| 796 |
+
|
| 797 |
+
200
|
| 798 |
+
00:17:07,000 --> 00:17:14,000
|
| 799 |
+
These are masses that are used to perform the desired transition between two states of any resource.
|
| 800 |
+
|
| 801 |
+
201
|
| 802 |
+
00:17:14,000 --> 00:17:21,000
|
| 803 |
+
There is a common misunderstanding that HTTP methods and rest masses are the same thing.
|
| 804 |
+
|
| 805 |
+
202
|
| 806 |
+
00:17:21,000 --> 00:17:23,000
|
| 807 |
+
No, they are not.
|
| 808 |
+
|
| 809 |
+
203
|
| 810 |
+
00:17:23,000 --> 00:17:33,000
|
| 811 |
+
For example, rest dictates the usage of delete to erase a document, be it a file state etcetera behind
|
| 812 |
+
|
| 813 |
+
204
|
| 814 |
+
00:17:33,000 --> 00:17:34,000
|
| 815 |
+
the URI.
|
| 816 |
+
|
| 817 |
+
205
|
| 818 |
+
00:17:34,000 --> 00:17:45,000
|
| 819 |
+
Whereas with HTTP you would misuse probably a get or post query like this product and post with a parameter
|
| 820 |
+
|
| 821 |
+
206
|
| 822 |
+
00:17:45,000 --> 00:17:46,000
|
| 823 |
+
delete ID.
|
| 824 |
+
|
| 825 |
+
207
|
| 826 |
+
00:17:47,000 --> 00:17:56,000
|
| 827 |
+
Another example is if we decide that application APIs will use HTTP post for updating a resource rather
|
| 828 |
+
|
| 829 |
+
208
|
| 830 |
+
00:17:56,000 --> 00:17:59,000
|
| 831 |
+
than most people recommend http put.
|
| 832 |
+
|
| 833 |
+
209
|
| 834 |
+
00:17:59,000 --> 00:17:59,000
|
| 835 |
+
It's all.
|
| 836 |
+
|
| 837 |
+
210
|
| 838 |
+
00:18:00,000 --> 00:18:08,000
|
| 839 |
+
Still, the application interface will be restful, but just an advice to remember taking into account
|
| 840 |
+
|
| 841 |
+
211
|
| 842 |
+
00:18:08,000 --> 00:18:10,000
|
| 843 |
+
a rest doesn't have a standard.
|
| 844 |
+
|
| 845 |
+
212
|
| 846 |
+
00:18:11,000 --> 00:18:17,000
|
| 847 |
+
Make sure that everyone working on the product uses the same definition.
|
| 848 |
+
|
| 849 |
+
213
|
| 850 |
+
00:18:17,000 --> 00:18:21,000
|
| 851 |
+
This should be set by the development lead of your team.
|
| 852 |
+
|
| 853 |
+
214
|
| 854 |
+
00:18:22,000 --> 00:18:27,000
|
| 855 |
+
So we already started the topic about comparison of rest and HTTP.
|
| 856 |
+
|
| 857 |
+
215
|
| 858 |
+
00:18:28,000 --> 00:18:32,000
|
| 859 |
+
I would like to highlight that rest is not the same as HTTP.
|
| 860 |
+
|
| 861 |
+
216
|
| 862 |
+
00:18:33,000 --> 00:18:36,000
|
| 863 |
+
We can say it in the following way.
|
| 864 |
+
|
| 865 |
+
217
|
| 866 |
+
00:18:36,000 --> 00:18:40,000
|
| 867 |
+
Rest is the way HTTP should be used.
|
| 868 |
+
|
| 869 |
+
218
|
| 870 |
+
00:18:40,000 --> 00:18:42,000
|
| 871 |
+
Rest is not a standard.
|
| 872 |
+
|
| 873 |
+
219
|
| 874 |
+
00:18:43,000 --> 00:18:45,000
|
| 875 |
+
It is also not a protocol like HTTP.
|
| 876 |
+
|
| 877 |
+
220
|
| 878 |
+
00:18:46,000 --> 00:18:48,000
|
| 879 |
+
It is not even a specification.
|
| 880 |
+
|
| 881 |
+
221
|
| 882 |
+
00:18:48,000 --> 00:18:57,000
|
| 883 |
+
We already learned that rest is just an architectural style approach for distributed hypermedia systems
|
| 884 |
+
|
| 885 |
+
222
|
| 886 |
+
00:18:57,000 --> 00:19:02,000
|
| 887 |
+
and architectural principles and constraints that we discuss.
|
| 888 |
+
|
| 889 |
+
223
|
| 890 |
+
00:19:02,000 --> 00:19:10,000
|
| 891 |
+
It may help to create large interconnected systems such as the Internet and make them very efficient
|
| 892 |
+
|
| 893 |
+
224
|
| 894 |
+
00:19:10,000 --> 00:19:11,000
|
| 895 |
+
with high performance.
|
| 896 |
+
|
| 897 |
+
225
|
| 898 |
+
00:19:12,000 --> 00:19:16,000
|
| 899 |
+
On the other hand, HTTP is a protocol standard.
|
| 900 |
+
|
| 901 |
+
226
|
| 902 |
+
00:19:16,000 --> 00:19:19,000
|
| 903 |
+
While it is not the same as rest.
|
| 904 |
+
|
| 905 |
+
227
|
| 906 |
+
00:19:19,000 --> 00:19:25,000
|
| 907 |
+
It exhibits many features of a restful system in the world of HTTP.
|
| 908 |
+
|
| 909 |
+
228
|
| 910 |
+
00:19:25,000 --> 00:19:29,000
|
| 911 |
+
Resources are typically files on a remote server.
|
| 912 |
+
|
| 913 |
+
229
|
| 914 |
+
00:19:30,000 --> 00:19:40,000
|
| 915 |
+
This could be HTML, CSS, JavaScript images and all the other files that comprise modern web pages.
|
| 916 |
+
|
| 917 |
+
230
|
| 918 |
+
00:19:40,000 --> 00:19:46,000
|
| 919 |
+
Each file is treated as distinct resource that is addressable using a unique URL.
|
| 920 |
+
|
| 921 |
+
231
|
| 922 |
+
00:19:47,000 --> 00:19:56,000
|
| 923 |
+
One more difference between rest and the HTTP rest is not a communication protocol while HTTP is.
|
| 924 |
+
|
| 925 |
+
232
|
| 926 |
+
00:19:57,000 --> 00:20:04,000
|
| 927 |
+
And another difference pretty formal one, but still the most modern web servers use cookies and sessions
|
| 928 |
+
|
| 929 |
+
233
|
| 930 |
+
00:20:04,000 --> 00:20:06,000
|
| 931 |
+
to store state.
|
| 932 |
+
|
| 933 |
+
234
|
| 934 |
+
00:20:06,000 --> 00:20:13,000
|
| 935 |
+
And as you may already know that using cookies, we get access to the session object that is stored
|
| 936 |
+
|
| 937 |
+
235
|
| 938 |
+
00:20:13,000 --> 00:20:15,000
|
| 939 |
+
on the server side.
|
| 940 |
+
|
| 941 |
+
236
|
| 942 |
+
00:20:15,000 --> 00:20:24,000
|
| 943 |
+
And you remember that rest architecture says that client stores the state and the server is stateless.
|
| 944 |
+
|
| 945 |
+
237
|
| 946 |
+
00:20:24,000 --> 00:20:31,000
|
| 947 |
+
So when we use cookies and sessions on the server side formally, this is not anymore rest style.
|
| 948 |
+
|
| 949 |
+
238
|
| 950 |
+
00:20:32,000 --> 00:20:36,000
|
| 951 |
+
This is one of the controversial points to think about.
|
| 952 |
+
|
| 953 |
+
239
|
| 954 |
+
00:20:36,000 --> 00:20:44,000
|
| 955 |
+
So to sum it up, you are going to hear that different people still use such terms as rest and HTTP
|
| 956 |
+
|
| 957 |
+
240
|
| 958 |
+
00:20:44,000 --> 00:20:46,000
|
| 959 |
+
interchangeably.
|
| 960 |
+
|
| 961 |
+
241
|
| 962 |
+
00:20:46,000 --> 00:20:50,000
|
| 963 |
+
But as we already discussed, these are different things.
|
| 964 |
+
|
| 965 |
+
242
|
| 966 |
+
00:20:50,000 --> 00:20:52,000
|
| 967 |
+
And now you know why?
|
| 968 |
+
|
| 969 |
+
243
|
| 970 |
+
00:20:53,000 --> 00:20:56,000
|
| 971 |
+
That's all what I wanted to share with you in this lesson.
|
| 972 |
+
|
| 973 |
+
244
|
| 974 |
+
00:20:56,000 --> 00:20:59,000
|
| 975 |
+
Let's recap what we have learned today.
|
| 976 |
+
|
| 977 |
+
245
|
| 978 |
+
00:21:00,000 --> 00:21:04,000
|
| 979 |
+
Today we learned what rest and rest terms mean.
|
| 980 |
+
|
| 981 |
+
246
|
| 982 |
+
00:21:05,000 --> 00:21:09,000
|
| 983 |
+
I explained key principles of the rest architectural style.
|
| 984 |
+
|
| 985 |
+
247
|
| 986 |
+
00:21:09,000 --> 00:21:18,000
|
| 987 |
+
Namely, we talked about client server communication, stateless communication, caching, uniform interface,
|
| 988 |
+
|
| 989 |
+
248
|
| 990 |
+
00:21:18,000 --> 00:21:21,000
|
| 991 |
+
layered system and code on demand.
|
| 992 |
+
|
| 993 |
+
249
|
| 994 |
+
00:21:22,000 --> 00:21:27,000
|
| 995 |
+
Also I explained your concept of the resource in the rest architecture.
|
| 996 |
+
|
| 997 |
+
250
|
| 998 |
+
00:21:27,000 --> 00:21:36,000
|
| 999 |
+
We talked about resource methods and we compared rest with HTTP protocol to understand the difference.
|
| 1000 |
+
|
| 1001 |
+
251
|
| 1002 |
+
00:21:36,000 --> 00:21:38,000
|
| 1003 |
+
That's all for today.
|
| 1004 |
+
|
| 1005 |
+
252
|
| 1006 |
+
00:21:38,000 --> 00:21:40,000
|
| 1007 |
+
Thanks a lot for your attention.
|
| 1008 |
+
|
| 1009 |
+
253
|
| 1010 |
+
00:21:40,000 --> 00:21:44,000
|
| 1011 |
+
Have a great day and see you in the next lesson.
|
| 1012 |
+
|
91 - REST Architecture/002 Naming Convention for RESTful Services_en.srt
ADDED
|
@@ -0,0 +1,820 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:05,000 --> 00:00:06,000
|
| 3 |
+
Hello, team.
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:06,000 --> 00:00:12,000
|
| 7 |
+
In this video we are going to learn important things about naming convention in RESTful services.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:12,000 --> 00:00:17,000
|
| 11 |
+
This is important topic before we started creation of your rest API.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:17,000 --> 00:00:24,000
|
| 15 |
+
We are going to start our lesson from review and understanding of why it is important to follow guidelines
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:24,000 --> 00:00:29,000
|
| 19 |
+
and naming convention during the creation of restful service and the rest.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:29,000 --> 00:00:36,000
|
| 23 |
+
Part of the lesson will be dedicated to the discussion of the principles, rules, guidelines, recommendations.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:36,000 --> 00:00:41,000
|
| 27 |
+
They are use nouns to represent resources, not verbs.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:41,000 --> 00:00:50,000
|
| 31 |
+
Use pluralized nouns for resources, use hyphens and lowercase use forward slashes for Iraqi but not
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:50,000 --> 00:00:59,000
|
| 35 |
+
trailing forward slash avoid using file extensions API versioning use query parameters punctuation for
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:59,000 --> 00:01:05,000
|
| 39 |
+
list intuitive names no jargon no abridging.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:01:05,000 --> 00:01:11,000
|
| 43 |
+
Avoid using special characters and keep your API consistent.
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:01:11,000 --> 00:01:13,000
|
| 47 |
+
So let's start our lesson.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:01:14,000 --> 00:01:20,000
|
| 51 |
+
Let's try to understand first why this topic is so important and why I decided to dedicate the whole
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:01:20,000 --> 00:01:22,000
|
| 55 |
+
lesson to this topic.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:01:22,000 --> 00:01:24,000
|
| 59 |
+
Design of the API.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:01:24,000 --> 00:01:30,000
|
| 63 |
+
It is super important task because most likely multiple clients and very often multiple generations
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:01:30,000 --> 00:01:33,000
|
| 67 |
+
of other developers and clients are going to use it.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:01:33,000 --> 00:01:41,000
|
| 71 |
+
And to ensure scalability of your API efficient support, it is better to follow some standards and
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:01:41,000 --> 00:01:44,000
|
| 75 |
+
guidelines during the naming your APIs.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:01:45,000 --> 00:01:51,000
|
| 79 |
+
This will save us from having additional issues related with misunderstanding and potential errors.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:01:52,000 --> 00:01:58,000
|
| 83 |
+
Because at the end of the day our API should be intuitive and built in the logical way.
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:01:58,000 --> 00:02:06,000
|
| 87 |
+
Very often I don't even look at the documentation because I assume that in case entity is named in this
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:02:06,000 --> 00:02:13,000
|
| 91 |
+
way, then end point for collection of entities should be available with this name using this rest method.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:02:14,000 --> 00:02:15,000
|
| 95 |
+
Do you understand my point?
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:02:15,000 --> 00:02:21,000
|
| 99 |
+
Knowing the best practices for naming your restful APIs is particularly important.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:02:21,000 --> 00:02:28,000
|
| 103 |
+
Using Rest API and naming conventions dramatically lowers the learning curve and makes it easier for
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:02:28,000 --> 00:02:33,000
|
| 107 |
+
new developers and third party users to start with the API.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:02:33,000 --> 00:02:39,000
|
| 111 |
+
The more people understand how to use the proper methods, the easier it is for everyone.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:02:39,000 --> 00:02:45,000
|
| 115 |
+
These standards should be required for every UI naming process.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:02:45,000 --> 00:02:52,000
|
| 119 |
+
That's why I decided to hold this lesson before we started learning the implementation part of the rest
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:02:52,000 --> 00:02:53,000
|
| 123 |
+
Architecture.
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:02:54,000 --> 00:02:59,000
|
| 127 |
+
The Danger lesson we are going to review the most popular and important guidelines is that I strongly
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:02:59,000 --> 00:03:04,000
|
| 131 |
+
recommend you to follow during designing your API and naming endpoints.
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:03:05,000 --> 00:03:11,000
|
| 135 |
+
I've already shared the list of recommendations that we are going to review today during the agenda.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:03:11,000 --> 00:03:18,000
|
| 139 |
+
So let's just go one by one and the first recommendations that we are going to review sounds like this.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:03:19,000 --> 00:03:23,000
|
| 143 |
+
Use nouns to represent resources, but not verbs.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:03:23,000 --> 00:03:32,000
|
| 147 |
+
Basically the resource identifier its UI shouldn't declare any create, read, update or delete operations.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:03:32,000 --> 00:03:38,000
|
| 151 |
+
You have request methods for that to define what should be done with the resource.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:03:38,000 --> 00:03:41,000
|
| 155 |
+
Read, create, update or delete.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:03:41,000 --> 00:03:48,000
|
| 159 |
+
But instead you need to define the noun, the name of the resource that you interact with.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:03:49,000 --> 00:03:58,000
|
| 163 |
+
RESTful Uris should refer to a resource that is a sink noun instead of referring to an action verb.
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:03:59,000 --> 00:04:03,000
|
| 167 |
+
Because nouns have properties which verbs do not have.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:04:03,000 --> 00:04:06,000
|
| 171 |
+
Similar to resources have attributes.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:04:07,000 --> 00:04:10,000
|
| 175 |
+
On the slide you can see good and bad examples.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:04:10,000 --> 00:04:13,000
|
| 179 |
+
Pay attention also to the delete orders.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:04:13,000 --> 00:04:14,000
|
| 183 |
+
Uri.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:04:14,000 --> 00:04:18,000
|
| 187 |
+
It is kind of a verb noun combination.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:04:18,000 --> 00:04:21,000
|
| 191 |
+
It is also not recommended to do like that.
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:04:22,000 --> 00:04:28,000
|
| 195 |
+
Looking at the good examples, I believe you can agree with me that they are readable and intuitive.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:04:29,000 --> 00:04:37,000
|
| 199 |
+
Obviously that resource with employees identifier and employee ID requested via get method should read
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:04:37,000 --> 00:04:41,000
|
| 203 |
+
the resource with an ID of specific employee entity.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:04:42,000 --> 00:04:46,000
|
| 207 |
+
This is simple rule to follow, so just please don't forget it.
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:04:47,000 --> 00:04:53,000
|
| 211 |
+
The next thing that probably you are thinking about right now, if we use nouns, should we use plural
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:04:53,000 --> 00:04:54,000
|
| 215 |
+
or singular?
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:04:55,000 --> 00:05:01,000
|
| 219 |
+
Of course this is a matter of your own preference, but the rule of thumb is to use plurals for all
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:05:01,000 --> 00:05:06,000
|
| 223 |
+
resources unless they are singleton resources, for example.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:05:06,000 --> 00:05:09,000
|
| 227 |
+
Config y plurals.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:05:09,000 --> 00:05:16,000
|
| 231 |
+
Well, they are just more preferred because they represent more of something generic in a sense.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:05:17,000 --> 00:05:23,000
|
| 235 |
+
On this slide you can see bad and good examples with item and employee endpoints.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:05:23,000 --> 00:05:25,000
|
| 239 |
+
Let's continue.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:05:25,000 --> 00:05:33,000
|
| 243 |
+
The next recommendation to follow is to use hyphens to separate words and use lowercase for all words.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:05:33,000 --> 00:05:34,000
|
| 247 |
+
Don't use camel.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:05:35,000 --> 00:05:45,000
|
| 251 |
+
Don't use underscores the RFC 1786 specification for your rise standards also denotes that your eyes
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:05:45,000 --> 00:05:52,000
|
| 255 |
+
are case sensitive except for the scheme and host components of the URL.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:05:52,000 --> 00:06:00,000
|
| 259 |
+
Given the widespread use of it, avoid any unnecessary confusion due to inconsistent capitalization.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:06:00,000 --> 00:06:08,000
|
| 263 |
+
Rest API can be developed by backend developers with different primary skills, and you know that in
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:06:08,000 --> 00:06:11,000
|
| 267 |
+
different programming languages there are different names.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:06:11,000 --> 00:06:12,000
|
| 271 |
+
Style.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:06:12,000 --> 00:06:16,000
|
| 275 |
+
For example, in PHP it is common to use underscores.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:06:16,000 --> 00:06:23,000
|
| 279 |
+
In Java and C sharp, it is common to use camelcase and sometimes engineers either forget or just want
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:06:23,000 --> 00:06:28,000
|
| 283 |
+
to apply their own habits while designing the rest API.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:06:28,000 --> 00:06:33,000
|
| 287 |
+
So remember the recommendation is to use hyphens to separate words.
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:06:33,000 --> 00:06:36,000
|
| 291 |
+
It is more readable and user friendly.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:06:36,000 --> 00:06:43,000
|
| 295 |
+
Also, hyphens are much better for Google search as hyphens are recommended by Google itself to make
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:06:43,000 --> 00:06:49,000
|
| 299 |
+
its web crawling job easier, thus creating more consistent results.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:06:50,000 --> 00:06:53,000
|
| 303 |
+
You can review good and bad examples on the slide.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:06:54,000 --> 00:07:00,000
|
| 307 |
+
The next rule is to use forward slashes for Iraqi but not trailing forward slash.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:07:00,000 --> 00:07:03,000
|
| 311 |
+
Let me explain what this rule is all about.
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:07:04,000 --> 00:07:09,000
|
| 315 |
+
Usually forward slashes are used for the show in the Iraqi normal.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:07:09,000 --> 00:07:15,000
|
| 319 |
+
People might not know why the words in the link are separated by forward slashes.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:07:16,000 --> 00:07:23,000
|
| 323 |
+
As a developer, you should be familiar with the reason the forward slashes denote the UI.
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:07:23,000 --> 00:07:32,000
|
| 327 |
+
Iraqi APIs are typically structured in Iraqi, but there is no need to use slash at the end of the endpoint.
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:07:33,000 --> 00:07:34,000
|
| 331 |
+
Okay, let's move on.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:07:35,000 --> 00:07:41,000
|
| 335 |
+
The next guideline that I would like to review with you is about not adding file extensions to the Uris.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:07:41,000 --> 00:07:45,000
|
| 339 |
+
There is just no need in adding file extensions to the URI.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:07:46,000 --> 00:07:50,000
|
| 343 |
+
File extension simply adds unnecessary length and complexity.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:07:51,000 --> 00:07:58,000
|
| 347 |
+
Imagine that you would like to change the format of response instead of JSON to return XML and what
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:07:58,000 --> 00:07:59,000
|
| 351 |
+
to do.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:07:59,000 --> 00:08:07,000
|
| 355 |
+
You need to change API to update the endpoint and you also need to update your client and documentation.
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:08:07,000 --> 00:08:14,000
|
| 359 |
+
There are unnecessary actions that you can avoid in case you just don't use the file extensions as a
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:08:14,000 --> 00:08:15,000
|
| 363 |
+
part of the URI.
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:08:16,000 --> 00:08:22,000
|
| 367 |
+
Again, I recommend you observe bad and good examples presented on the slide.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:08:22,000 --> 00:08:26,000
|
| 371 |
+
Another important recommendation is to version your API.
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:08:27,000 --> 00:08:34,000
|
| 375 |
+
Always mark your API with the version because imagine that you want to introduce improvements or upgrades
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:08:34,000 --> 00:08:41,000
|
| 379 |
+
that change the way how API works or change even the name of a resource which is not recommended.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:08:41,000 --> 00:08:46,000
|
| 383 |
+
But still there can be cases and you have a few challenges.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:08:46,000 --> 00:08:52,000
|
| 387 |
+
The first one How to ensure compatibility of your client with the existing API.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:08:52,000 --> 00:08:59,000
|
| 391 |
+
The second one How to make all clients aware that significant changes are released and they need to
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:08:59,000 --> 00:09:03,000
|
| 395 |
+
take changes into consideration when they process the response.
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:09:03,000 --> 00:09:09,000
|
| 399 |
+
So never think about your API like something final and usable forever.
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:09:10,000 --> 00:09:16,000
|
| 403 |
+
There is always a chance that new features will be added or some changes to the existing API will be
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:09:16,000 --> 00:09:23,000
|
| 407 |
+
introduced and you never want to break your existing and working API that is already used by clients.
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:09:23,000 --> 00:09:30,000
|
| 411 |
+
Also, when you are using versioning from the very beginning and documented, it indirectly tells the
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:09:30,000 --> 00:09:34,000
|
| 415 |
+
users that there might be changes in the future.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:09:34,000 --> 00:09:39,000
|
| 419 |
+
It is good to prepare your users for any upcoming changes ahead of time.
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:09:39,000 --> 00:09:44,000
|
| 423 |
+
You can specify a version in the left part of the endpoint in order.
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:09:44,000 --> 00:09:46,000
|
| 427 |
+
The version has the highest scope.
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:09:47,000 --> 00:09:53,000
|
| 431 |
+
Your clients will be interested only in the major version updates, so it will be enough to specify
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:09:53,000 --> 00:09:58,000
|
| 435 |
+
just major versions like version one or version two, etcetera.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:09:59,000 --> 00:10:01,000
|
| 439 |
+
Just like in the example on the slide.
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:10:02,000 --> 00:10:10,000
|
| 443 |
+
By doing so, if the API is being used by external entities, changing the endpoint will not really
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:10:10,000 --> 00:10:12,000
|
| 447 |
+
affect the existing ones.
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:10:13,000 --> 00:10:17,000
|
| 451 |
+
I like this approach, but there are also four other ways of versioning.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:10:18,000 --> 00:10:26,000
|
| 455 |
+
They are versioning in the subdomain versioning as an additional header, versioning as an additional
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:10:26,000 --> 00:10:32,000
|
| 459 |
+
field in the accept content type header, versioning as a media type.
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:10:32,000 --> 00:10:33,000
|
| 463 |
+
Let's review them.
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:10:34,000 --> 00:10:36,000
|
| 467 |
+
Versioning in the subdomain.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:10:36,000 --> 00:10:43,000
|
| 471 |
+
This one puts the version within the UI but makes it associated with the domain like you can see on
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:10:43,000 --> 00:10:44,000
|
| 475 |
+
the slide.
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:10:44,000 --> 00:10:48,000
|
| 479 |
+
This is very similar to the version in placed at the end.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:10:48,000 --> 00:10:56,000
|
| 483 |
+
However, this approach has one advantage that can allow you to host your API on different servers.
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:10:57,000 --> 00:11:00,000
|
| 487 |
+
Another approach is versioning as an additional header.
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:11:00,000 --> 00:11:04,000
|
| 491 |
+
This version uses Mimetypes to include the API version.
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:11:05,000 --> 00:11:08,000
|
| 495 |
+
It looks something like you can see on this slide.
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:11:09,000 --> 00:11:13,000
|
| 499 |
+
Version as an additional field in the accept Content-type header.
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:11:13,000 --> 00:11:19,000
|
| 503 |
+
This one is similar to the previous point that we discussed on how to include it.
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:11:19,000 --> 00:11:22,000
|
| 507 |
+
Except is the result is different.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:11:22,000 --> 00:11:24,000
|
| 511 |
+
Here is how it looks like.
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:11:24,000 --> 00:11:28,000
|
| 515 |
+
Pay attention to this slide to understand the difference.
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:11:29,000 --> 00:11:31,000
|
| 519 |
+
Versioning as a media type.
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:11:31,000 --> 00:11:37,000
|
| 523 |
+
This is also similar as the three previous ways all use the Mimetypes sync.
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:11:38,000 --> 00:11:42,000
|
| 527 |
+
The only differences are where or how to put the versioning.
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:11:42,000 --> 00:11:46,000
|
| 531 |
+
Here are some examples presented on the slide.
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:11:47,000 --> 00:11:53,000
|
| 535 |
+
The next guideline that we are going to discuss is about using query parameters in your API.
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:11:53,000 --> 00:12:00,000
|
| 539 |
+
Very often you are going to have requirements to support filtering or sorting or pagination, and to
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:12:00,000 --> 00:12:04,000
|
| 543 |
+
implement this requirement you would need to take into account input parameters.
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:12:04,000 --> 00:12:13,000
|
| 547 |
+
It can be field that is used for sorting and sorting order or filtering criteria and instead of creating
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:12:13,000 --> 00:12:16,000
|
| 551 |
+
new API use query parameters.
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:12:16,000 --> 00:12:23,000
|
| 555 |
+
For example, if you want to filter users to keep in the collection, only those where location is equal
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:12:23,000 --> 00:12:29,000
|
| 559 |
+
to USA, then you can use location query parameter like you can see on the slide.
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:12:30,000 --> 00:12:36,000
|
| 563 |
+
Or in case you want to declare multiple filtering criteria, you can use something like you can see
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:12:36,000 --> 00:12:42,000
|
| 567 |
+
in another example on the slide when I used department and region criteria.
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:12:43,000 --> 00:12:48,000
|
| 571 |
+
Another helpful advice that I want to give you is to use punctuation for lists.
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:12:48,000 --> 00:12:53,000
|
| 575 |
+
Sometimes we want to allow client to fetch multiple resources.
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:12:53,000 --> 00:13:01,000
|
| 579 |
+
In such cases we can use punctuation, comma or semicolon, but comma is used more often.
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:13:01,000 --> 00:13:05,000
|
| 583 |
+
If client wants to access multiple user resources.
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:13:05,000 --> 00:13:10,000
|
| 587 |
+
We can design our API in the way like you can see on the screen.
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:13:10,000 --> 00:13:15,000
|
| 591 |
+
You can see that between ID one and two there is a comma.
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:13:15,000 --> 00:13:18,000
|
| 595 |
+
The next guidelines that I would like to review is use.
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:13:18,000 --> 00:13:20,000
|
| 599 |
+
Sounds pretty logical and simple.
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:13:20,000 --> 00:13:23,000
|
| 603 |
+
Make your names intuitive.
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:13:23,000 --> 00:13:30,000
|
| 607 |
+
Try to select simplest and the most commonly used word to refer to a given concept.
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:13:30,000 --> 00:13:37,000
|
| 611 |
+
Your endpoint names and resource names should be self-describing and easy to understand.
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:13:37,000 --> 00:13:42,000
|
| 615 |
+
It should save time of clients and developers when interacting with the API.
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:13:42,000 --> 00:13:49,000
|
| 619 |
+
When you design an API and trying to come up with the name, try to position yourself as a consumer,
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:13:49,000 --> 00:13:53,000
|
| 623 |
+
as someone who doesn't know anything about your services.
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:13:54,000 --> 00:14:01,000
|
| 627 |
+
I would expect to be able to understand the basic use of API just by reading the API endpoints naming.
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:14:02,000 --> 00:14:07,000
|
| 631 |
+
If I would like to fully understand how to use it, then I would read deeper.
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:14:07,000 --> 00:14:11,000
|
| 635 |
+
Ideally, the name has to be something that represents a whole.
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:14:12,000 --> 00:14:19,000
|
| 639 |
+
In addition, you would like to avoid causing confusion by avoiding abbreviations or shorthand as well.
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:14:19,000 --> 00:14:26,000
|
| 643 |
+
For example, when you name a resource as users from the name, it is clear that with this endpoint
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:14:26,000 --> 00:14:31,000
|
| 647 |
+
you can access user resource and get user information.
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:14:31,000 --> 00:14:33,000
|
| 651 |
+
Resource has a lot of data.
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:14:33,000 --> 00:14:40,000
|
| 655 |
+
We can make this conclusion by plural version of the noun and logical addition to this rule.
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:14:40,000 --> 00:14:43,000
|
| 659 |
+
Avoid using jargon.
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:14:43,000 --> 00:14:46,000
|
| 663 |
+
Clients shouldn't spend time guessing.
|
| 664 |
+
|
| 665 |
+
167
|
| 666 |
+
00:14:47,000 --> 00:14:50,000
|
| 667 |
+
Use less domain centric jargon.
|
| 668 |
+
|
| 669 |
+
168
|
| 670 |
+
00:14:50,000 --> 00:14:57,000
|
| 671 |
+
Sometimes that's common and more understandable is going to make your APIs a lot more usable.
|
| 672 |
+
|
| 673 |
+
169
|
| 674 |
+
00:14:58,000 --> 00:15:00,000
|
| 675 |
+
Pay attention to the example on the slide.
|
| 676 |
+
|
| 677 |
+
170
|
| 678 |
+
00:15:01,000 --> 00:15:06,000
|
| 679 |
+
For example, in this case, what does f n mean?
|
| 680 |
+
|
| 681 |
+
171
|
| 682 |
+
00:15:06,000 --> 00:15:07,000
|
| 683 |
+
Function?
|
| 684 |
+
|
| 685 |
+
172
|
| 686 |
+
00:15:07,000 --> 00:15:08,000
|
| 687 |
+
Which function?
|
| 688 |
+
|
| 689 |
+
173
|
| 690 |
+
00:15:08,000 --> 00:15:09,000
|
| 691 |
+
This is not clear.
|
| 692 |
+
|
| 693 |
+
174
|
| 694 |
+
00:15:09,000 --> 00:15:15,000
|
| 695 |
+
So stick with your common sense and choose intuitive, clear names.
|
| 696 |
+
|
| 697 |
+
175
|
| 698 |
+
00:15:16,000 --> 00:15:23,000
|
| 699 |
+
Another guideline that we partially discussed recommendations that is also follows from the previous
|
| 700 |
+
|
| 701 |
+
176
|
| 702 |
+
00:15:23,000 --> 00:15:24,000
|
| 703 |
+
one.
|
| 704 |
+
|
| 705 |
+
177
|
| 706 |
+
00:15:24,000 --> 00:15:28,000
|
| 707 |
+
Avoid obliging and point resource names.
|
| 708 |
+
|
| 709 |
+
178
|
| 710 |
+
00:15:28,000 --> 00:15:37,000
|
| 711 |
+
In fact, branch names can actually create confusion in your API as developers struggle to guess and
|
| 712 |
+
|
| 713 |
+
179
|
| 714 |
+
00:15:37,000 --> 00:15:40,000
|
| 715 |
+
sometimes understand the names you have chosen.
|
| 716 |
+
|
| 717 |
+
180
|
| 718 |
+
00:15:40,000 --> 00:15:45,000
|
| 719 |
+
For example, there is no need to use tell no end point.
|
| 720 |
+
|
| 721 |
+
181
|
| 722 |
+
00:15:45,000 --> 00:15:48,000
|
| 723 |
+
It is better to use phone number.
|
| 724 |
+
|
| 725 |
+
182
|
| 726 |
+
00:15:48,000 --> 00:15:55,000
|
| 727 |
+
Another simple but also important recommendation is to avoid using special characters.
|
| 728 |
+
|
| 729 |
+
183
|
| 730 |
+
00:15:55,000 --> 00:16:00,000
|
| 731 |
+
I understand that this is logical, but still it is a guideline to remember.
|
| 732 |
+
|
| 733 |
+
184
|
| 734 |
+
00:16:01,000 --> 00:16:07,000
|
| 735 |
+
Sinks like person signed 20 which represents the space character should not be used either.
|
| 736 |
+
|
| 737 |
+
185
|
| 738 |
+
00:16:08,000 --> 00:16:15,000
|
| 739 |
+
Again, Z is in itself already goes against the intuitive naming convention.
|
| 740 |
+
|
| 741 |
+
186
|
| 742 |
+
00:16:15,000 --> 00:16:23,000
|
| 743 |
+
So try to avoid using characters like person signed 20 in your naming as those have other meanings already.
|
| 744 |
+
|
| 745 |
+
187
|
| 746 |
+
00:16:24,000 --> 00:16:28,000
|
| 747 |
+
We review today a lot of guidelines and recommendations.
|
| 748 |
+
|
| 749 |
+
188
|
| 750 |
+
00:16:28,000 --> 00:16:35,000
|
| 751 |
+
And the last but not the least guideline is about consistency in your API because consistency is a key
|
| 752 |
+
|
| 753 |
+
189
|
| 754 |
+
00:16:35,000 --> 00:16:38,000
|
| 755 |
+
and it deserves special recognition.
|
| 756 |
+
|
| 757 |
+
190
|
| 758 |
+
00:16:39,000 --> 00:16:47,000
|
| 759 |
+
Always use the same name to refer to a given concept within your API, because even in case you follow
|
| 760 |
+
|
| 761 |
+
191
|
| 762 |
+
00:16:47,000 --> 00:16:51,000
|
| 763 |
+
all other guidelines that we reviewed, they were nothing.
|
| 764 |
+
|
| 765 |
+
192
|
| 766 |
+
00:16:51,000 --> 00:16:54,000
|
| 767 |
+
If your API is inconsistent.
|
| 768 |
+
|
| 769 |
+
193
|
| 770 |
+
00:16:55,000 --> 00:16:57,000
|
| 771 |
+
That's all what I wanted to share with you today.
|
| 772 |
+
|
| 773 |
+
194
|
| 774 |
+
00:16:57,000 --> 00:17:01,000
|
| 775 |
+
Let's recap what we have learned in the lesson.
|
| 776 |
+
|
| 777 |
+
195
|
| 778 |
+
00:17:01,000 --> 00:17:07,000
|
| 779 |
+
Today we learn two key principles and guidelines that are recommended to follow while designing your
|
| 780 |
+
|
| 781 |
+
196
|
| 782 |
+
00:17:07,000 --> 00:17:09,000
|
| 783 |
+
Rest API and RESTful services.
|
| 784 |
+
|
| 785 |
+
197
|
| 786 |
+
00:17:09,000 --> 00:17:15,000
|
| 787 |
+
We learned such guidelines use nouns to represent resources, not verbs.
|
| 788 |
+
|
| 789 |
+
198
|
| 790 |
+
00:17:15,000 --> 00:17:24,000
|
| 791 |
+
We use pluralized nouns for resources, use hyphens and lowercase use forward slashes for Iraqi but
|
| 792 |
+
|
| 793 |
+
199
|
| 794 |
+
00:17:24,000 --> 00:17:33,000
|
| 795 |
+
not trailing forward slash avoid using file extensions API versioning use query parameters punctuation
|
| 796 |
+
|
| 797 |
+
200
|
| 798 |
+
00:17:33,000 --> 00:17:38,000
|
| 799 |
+
for lists intuitive names No jargon no abridging.
|
| 800 |
+
|
| 801 |
+
201
|
| 802 |
+
00:17:39,000 --> 00:17:41,000
|
| 803 |
+
Avoid using special characters.
|
| 804 |
+
|
| 805 |
+
202
|
| 806 |
+
00:17:41,000 --> 00:17:43,000
|
| 807 |
+
Keep your API consistent.
|
| 808 |
+
|
| 809 |
+
203
|
| 810 |
+
00:17:44,000 --> 00:17:45,000
|
| 811 |
+
That's it.
|
| 812 |
+
|
| 813 |
+
204
|
| 814 |
+
00:17:45,000 --> 00:17:47,000
|
| 815 |
+
Thanks a lot for your attention.
|
| 816 |
+
|
| 817 |
+
205
|
| 818 |
+
00:17:47,000 --> 00:17:50,000
|
| 819 |
+
Have a great day and see you in the next lesson.
|
| 820 |
+
|
91 - REST Architecture/003 RESTful Service Implementation with Spring MVC_en.srt
ADDED
|
@@ -0,0 +1,1092 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:05,000 --> 00:00:06,000
|
| 3 |
+
Hello, team.
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:06,000 --> 00:00:15,000
|
| 7 |
+
By this moment in our course, we learned what raster architecture is and learned RESTful service naming
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:15,000 --> 00:00:16,000
|
| 11 |
+
convention.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:16,000 --> 00:00:24,000
|
| 15 |
+
We are ready to jump to the practical exercises and start implementation of our own restful service.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:24,000 --> 00:00:30,000
|
| 19 |
+
I must admit that there are different frameworks, different tools, and different programming languages
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:30,000 --> 00:00:33,000
|
| 23 |
+
that you can use to create restful service.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:33,000 --> 00:00:37,000
|
| 27 |
+
In this lesson, we are going to create our restful service using Spring MVC.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:37,000 --> 00:00:43,000
|
| 31 |
+
We will start our lesson with the configuration of the required dependencies.
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:43,000 --> 00:00:48,000
|
| 35 |
+
Then we will jump to creation of our first custom rest web service.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:48,000 --> 00:00:55,000
|
| 39 |
+
I'm going to explain you how to use rest controller annotation and how it is different from the controller
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:55,000 --> 00:00:56,000
|
| 43 |
+
annotation.
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:56,000 --> 00:01:01,000
|
| 47 |
+
We will learn such annotations and configurations as response body.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:01:01,000 --> 00:01:08,000
|
| 51 |
+
Request body pass a variable request param response status response entity.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:01:08,000 --> 00:01:15,000
|
| 55 |
+
And at the end of the lesson I'm going to show you how we can read HTTP headers in rest controller We
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:01:15,000 --> 00:01:17,000
|
| 59 |
+
are request header annotation.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:01:18,000 --> 00:01:24,000
|
| 63 |
+
Let's start our lesson and take into account that this is going to be practical lesson.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:01:24,000 --> 00:01:27,000
|
| 67 |
+
Let's jump to practical exercises.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:01:27,000 --> 00:01:32,000
|
| 71 |
+
As always, you can find source code examples in attachments to the lesson.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:01:33,000 --> 00:01:38,000
|
| 75 |
+
Feel free to clone the repository and run the code examples from the lesson locally.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:01:39,000 --> 00:01:41,000
|
| 79 |
+
I'm starting screen sharing.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:01:41,000 --> 00:01:48,000
|
| 83 |
+
Just a reminder that this is the lesson about creation of restful service with spring MVC, but not
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:01:48,000 --> 00:01:51,000
|
| 87 |
+
about spring MVC itself.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:01:51,000 --> 00:01:54,000
|
| 91 |
+
So my assumption is that you have clear understanding already.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:01:54,000 --> 00:02:00,000
|
| 95 |
+
What is spring MVC is, you know, how to configure component scanning of the elements, how to declare
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:02:00,000 --> 00:02:04,000
|
| 99 |
+
configuration, how to use web application, initializer.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:02:04,000 --> 00:02:10,000
|
| 103 |
+
I will not stop on the questions that we have already learned in the spring MVC section of my course.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:02:10,000 --> 00:02:12,000
|
| 107 |
+
Java from zero to first job.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:02:12,000 --> 00:02:18,000
|
| 111 |
+
If you would like to learn more, feel free to check the section of the course about Spring MVC where
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:02:18,000 --> 00:02:23,000
|
| 115 |
+
I explained in the details how to kick off spring MVC application.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:02:24,000 --> 00:02:28,000
|
| 119 |
+
Okay, let's continue with the dependencies overview.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:02:28,000 --> 00:02:35,000
|
| 123 |
+
If you follow my course Java from zero to first job where we implement our own online shop from scratch,
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:02:35,000 --> 00:02:41,000
|
| 127 |
+
then you should already have all required dependencies in your pom.xml file declared.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:02:41,000 --> 00:02:46,000
|
| 131 |
+
But just in case you jump directly to this lesson, let me recap.
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:02:46,000 --> 00:02:53,000
|
| 135 |
+
What are the key dependencies should be present in the classpath in order you can succeed with examples
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:02:53,000 --> 00:02:55,000
|
| 139 |
+
from this lesson.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:02:55,000 --> 00:03:01,000
|
| 143 |
+
The main thing is that you have spring MVC dependency, spring context and Jackson data bind.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:03:02,000 --> 00:03:06,000
|
| 147 |
+
These dependencies are the key for today's examples.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:03:06,000 --> 00:03:13,000
|
| 151 |
+
The rest of the dependencies depend on the tools and frameworks that you are going to use on the persistence
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:03:13,000 --> 00:03:14,000
|
| 155 |
+
level.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:03:14,000 --> 00:03:20,000
|
| 159 |
+
If you follow my course Java from zero to first job, then by this moment in our course you already
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:03:20,000 --> 00:03:28,000
|
| 163 |
+
learned how to work with Spring data JPA and Spring JDBC and can work with any of these tools on the
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:03:28,000 --> 00:03:29,000
|
| 167 |
+
persistence layer.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:03:30,000 --> 00:03:35,000
|
| 171 |
+
So I assume that you can add all relevant dependencies for the persistence layer.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:03:36,000 --> 00:03:43,000
|
| 175 |
+
All examples that I prepared for this lesson are located under the rest package in the user rest controller
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:03:43,000 --> 00:03:44,000
|
| 179 |
+
class.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:03:44,000 --> 00:03:51,000
|
| 183 |
+
All other classes that are going to be used today were reviewed in previous lessons, so I wouldn't
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:03:51,000 --> 00:03:51,000
|
| 187 |
+
stop on them.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:03:52,000 --> 00:04:00,000
|
| 191 |
+
For example, pay attention that I inject user service here and user service in turn uses user repository.
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:04:01,000 --> 00:04:07,000
|
| 195 |
+
As I said, if you want to get more detailed comments about persistence layer, feel free to check previous
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:04:07,000 --> 00:04:14,000
|
| 199 |
+
lessons from my course Java from zero to first job about spring data, JPA and Spring JDBC.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:04:14,000 --> 00:04:20,000
|
| 203 |
+
And in this lesson we will focus only on designing of our rest endpoints.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:04:20,000 --> 00:04:25,000
|
| 207 |
+
And the first concept that we need to talk about is understanding the difference between controller
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:04:25,000 --> 00:04:27,000
|
| 211 |
+
and rest controller.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:04:27,000 --> 00:04:35,000
|
| 215 |
+
So when we implement controller in spring, usually we market with controller annotation.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:04:35,000 --> 00:04:42,000
|
| 219 |
+
This is just a specialization of the component annotation that we use to mark our components in order.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:04:42,000 --> 00:04:45,000
|
| 223 |
+
Spring can manage life cycles of these beans.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:04:45,000 --> 00:04:50,000
|
| 227 |
+
It allows to auto detect implementation classes by classpath scanning.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:04:51,000 --> 00:04:56,000
|
| 231 |
+
Rest controller is a specialized version of the controller annotation.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:04:56,000 --> 00:05:02,000
|
| 235 |
+
If we open source code of rest controller annotation we would notice it is.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:05:02,000 --> 00:05:07,000
|
| 239 |
+
Is marked with controller annotation and response body annotation.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:05:07,000 --> 00:05:09,000
|
| 243 |
+
So in simple words.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:05:09,000 --> 00:05:16,000
|
| 247 |
+
Rest controller annotation is just a combination of controller and response body annotations.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:05:16,000 --> 00:05:23,000
|
| 251 |
+
This simplifies the implementation from the development side because in case you use rest controller.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:05:23,000 --> 00:05:27,000
|
| 255 |
+
Annotation you should not use response body annotation.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:05:27,000 --> 00:05:30,000
|
| 259 |
+
So what does response body annotation do?
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:05:30,000 --> 00:05:37,000
|
| 263 |
+
This annotation tells the controller that the object returned should be serialized into the JSON format
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:05:37,000 --> 00:05:41,000
|
| 267 |
+
and passed back in the HTTP response body.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:05:41,000 --> 00:05:46,000
|
| 271 |
+
That's why we added Jackson data bind in our dependencies.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:05:47,000 --> 00:05:52,000
|
| 275 |
+
Jackson Library is responsible for this JSON serialization.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:05:52,000 --> 00:06:00,000
|
| 279 |
+
In the example you can see that I can add produces attribute and specify media type that this endpoint
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:06:00,000 --> 00:06:06,000
|
| 283 |
+
supposed to produce response body will consider this configuration.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:06:06,000 --> 00:06:14,000
|
| 287 |
+
In this example, I vividly specified that JSON value will be returned, but JSON is used by default.
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:06:15,000 --> 00:06:22,000
|
| 291 |
+
I can open media type class just to show you that there are different constants available that you can
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:06:22,000 --> 00:06:24,000
|
| 295 |
+
specify instead of the JSON.
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:06:24,000 --> 00:06:31,000
|
| 299 |
+
Theoretically you can have multiple end points that are mapped to the same path, but that just produces
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:06:31,000 --> 00:06:33,000
|
| 303 |
+
output of different type.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:06:33,000 --> 00:06:41,000
|
| 307 |
+
Depending on the accept header of the HTTP request, it will be identified which endpoint will be invoked,
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:06:41,000 --> 00:06:45,000
|
| 311 |
+
and the first endpoint that is declared here is relatively simple.
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:06:45,000 --> 00:06:52,000
|
| 315 |
+
I just extract all users from the persistence layer and return the list of users.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:06:52,000 --> 00:06:54,000
|
| 319 |
+
So what will actually happen?
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:06:54,000 --> 00:07:01,000
|
| 323 |
+
Taking into account this is a rest controller, my list of users will be serialized into the JSON array
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:07:01,000 --> 00:07:03,000
|
| 327 |
+
and returned from the method.
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:07:04,000 --> 00:07:09,000
|
| 331 |
+
I'm going to show you this when we will come to testing of our API.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:07:10,000 --> 00:07:13,000
|
| 335 |
+
There is also annotations that is called request body.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:07:13,000 --> 00:07:16,000
|
| 339 |
+
It is not the same as response body.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:07:16,000 --> 00:07:20,000
|
| 343 |
+
So let's find out what is the difference in simple words.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:07:20,000 --> 00:07:30,000
|
| 347 |
+
The request body annotation Deserialize The HTTP request body into a Java object like this, we can
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:07:30,000 --> 00:07:33,000
|
| 351 |
+
pass resources to the restful service.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:07:33,000 --> 00:07:37,000
|
| 355 |
+
For example, we can send JSON of our user object.
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:07:37,000 --> 00:07:46,000
|
| 359 |
+
We have post method in order to create resource and in our method insert user you can see how I use
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:07:46,000 --> 00:07:48,000
|
| 363 |
+
request body annotation.
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:07:48,000 --> 00:07:56,000
|
| 367 |
+
Basically it will be again deserialized with the help of spring and Jackson data bind into the Java
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:07:56,000 --> 00:08:05,000
|
| 371 |
+
object and then I will use this Java object to store in my persistent storage by default the type we
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:08:05,000 --> 00:08:12,000
|
| 375 |
+
annotate with the request body annotation must correspond to the JSON sent from our client.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:08:12,000 --> 00:08:19,000
|
| 379 |
+
The next thing that we need to know in order to use it efficiently while implementing our restful service
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:08:19,000 --> 00:08:27,000
|
| 383 |
+
is pass variable annotation pass Verbal annotation can be used to handle template variables in the request
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:08:27,000 --> 00:08:32,000
|
| 387 |
+
URI mapping and set them as method parameters.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:08:32,000 --> 00:08:39,000
|
| 391 |
+
Like for example, you can see in the get user buy method, you can see that in the UI.
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:08:39,000 --> 00:08:47,000
|
| 395 |
+
I used variable and in the method parameters I use pass variable annotation in order to tell the spring
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:08:47,000 --> 00:08:55,000
|
| 399 |
+
that this variable value should be injected into this method argument in order, I can use it in the
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:08:55,000 --> 00:09:02,000
|
| 403 |
+
method during the implementation of the endpoint, you can use multiple pass variables as much as you
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:09:02,000 --> 00:09:05,000
|
| 407 |
+
need and to handle multiple pass variables.
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:09:05,000 --> 00:09:10,000
|
| 411 |
+
We can use map like you can see here in the command line.
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:09:10,000 --> 00:09:17,000
|
| 415 |
+
By default, values for all pass variables are mandatory in case it will be needed.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:09:17,000 --> 00:09:25,000
|
| 419 |
+
You can set required attribute of pass variable to false because in case you would leave pass variable
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:09:25,000 --> 00:09:33,000
|
| 423 |
+
as required and you wouldn't send it, exception will be produced, but actually usually we specify
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:09:33,000 --> 00:09:36,000
|
| 427 |
+
pass variables to make them required.
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:09:36,000 --> 00:09:40,000
|
| 431 |
+
So you shouldn't do something which is not logical during the development.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:09:40,000 --> 00:09:43,000
|
| 435 |
+
Just be aware that you have such tool set.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:09:44,000 --> 00:09:52,000
|
| 439 |
+
If you want to use optional API, then you can map pass variable with optional what optional API is
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:09:52,000 --> 00:09:54,000
|
| 443 |
+
and when to use it.
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:09:54,000 --> 00:10:01,000
|
| 447 |
+
You can check in the separate lesson in my course, but just quickly to remind you this API helps you
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:10:01,000 --> 00:10:02,000
|
| 451 |
+
to handle different.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:10:03,000 --> 00:10:06,000
|
| 455 |
+
This was no values, including no checks.
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:10:06,000 --> 00:10:13,000
|
| 459 |
+
And setting some default values in case is a reason now and many, many other different things.
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:10:13,000 --> 00:10:18,000
|
| 463 |
+
The next important configurations that we are going to use in our restful services.
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:10:18,000 --> 00:10:23,000
|
| 467 |
+
Building it with spring MVC is request param annotation.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:10:23,000 --> 00:10:29,000
|
| 471 |
+
Request parameterization helps us to extract query parameters from the request.
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:10:29,000 --> 00:10:36,000
|
| 475 |
+
Like in this example, when I want to fetch all users filtering them by the first name, you can see
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:10:36,000 --> 00:10:39,000
|
| 479 |
+
that first name is a query parameter.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:10:39,000 --> 00:10:42,000
|
| 483 |
+
In this case it is not pass variable.
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:10:42,000 --> 00:10:52,000
|
| 487 |
+
Also pay attention that the resource name is the same in different request mapping users and in order
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:10:52,000 --> 00:10:59,000
|
| 491 |
+
to not have an exception, that tells us that I have multiple same request mappings, I need to keep
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:10:59,000 --> 00:11:07,000
|
| 495 |
+
them different In case you would use different request method, the endpoints will become different.
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:11:07,000 --> 00:11:16,000
|
| 499 |
+
But in this particular case, everywhere I use get request method and in real life too you may have
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:11:16,000 --> 00:11:24,000
|
| 503 |
+
end point with the same name, same request method and you need to come up how to make these endpoints
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:11:24,000 --> 00:11:25,000
|
| 507 |
+
different.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:11:26,000 --> 00:11:33,000
|
| 511 |
+
I can keep them different by specifying the request parameters, but how was the question mark in the
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:11:33,000 --> 00:11:36,000
|
| 515 |
+
URI to keep them different?
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:11:36,000 --> 00:11:39,000
|
| 519 |
+
You don't need to use question mark in the URL mapping.
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:11:40,000 --> 00:11:47,000
|
| 523 |
+
What you have to do instead is to use params attribute in order to specify parameters name.
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:11:47,000 --> 00:11:54,000
|
| 527 |
+
This is how spring will differentiate endpoints with the same resource name but with different query
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:11:54,000 --> 00:11:55,000
|
| 531 |
+
parameters.
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:11:55,000 --> 00:12:01,000
|
| 535 |
+
It is important for you to understand that we are talking about not pass variable here.
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:12:02,000 --> 00:12:05,000
|
| 539 |
+
But the way how we work with it is similar.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:12:05,000 --> 00:12:13,000
|
| 543 |
+
You use request param annotation with the type and request parameter is injected into the method parameter.
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:12:13,000 --> 00:12:19,000
|
| 547 |
+
This is the simplest and the most common use case of using request parameter annotation.
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:12:20,000 --> 00:12:27,000
|
| 551 |
+
In the next example, you can see that I declared sort by request parameter and you can build logic
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:12:27,000 --> 00:12:31,000
|
| 555 |
+
for sorting based on the value passed with this parameter.
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:12:31,000 --> 00:12:39,000
|
| 559 |
+
In this example, in case somebody passed first name field, in this case I sort results by the first
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:12:39,000 --> 00:12:40,000
|
| 563 |
+
name.
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:12:40,000 --> 00:12:43,000
|
| 567 |
+
Otherwise I just return all users.
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:12:44,000 --> 00:12:48,000
|
| 571 |
+
Also created a few more requests parameter demo methods.
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:12:48,000 --> 00:12:50,000
|
| 575 |
+
Let's review them together.
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:12:50,000 --> 00:12:56,000
|
| 579 |
+
You can use request parameter with optional in order to get benefits of the optional API.
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:12:56,000 --> 00:13:01,000
|
| 583 |
+
You can specify whether the request parameter is required or no.
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:13:01,000 --> 00:13:09,000
|
| 587 |
+
In this case I specified that the request parameter is not mandatory and in case it will be absent there
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:13:09,000 --> 00:13:11,000
|
| 591 |
+
will not be any error.
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:13:11,000 --> 00:13:19,000
|
| 595 |
+
In case you expect to process multiple request parameters, you can use request parameter notation together
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:13:19,000 --> 00:13:22,000
|
| 599 |
+
with map during the program execution.
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:13:22,000 --> 00:13:30,000
|
| 603 |
+
All your request parameters will be injected into the map and after that you can iterate over the entries
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:13:30,000 --> 00:13:33,000
|
| 607 |
+
set to interact with the parameters.
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:13:33,000 --> 00:13:41,000
|
| 611 |
+
What to do In case I want to have endpoints that would read form data request parameters similar to
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:13:41,000 --> 00:13:45,000
|
| 615 |
+
the ones that we send via HTML forms.
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:13:45,000 --> 00:13:49,000
|
| 619 |
+
But note that we pass after the question mark in the URI.
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:13:50,000 --> 00:13:56,000
|
| 623 |
+
In this case, you can vividly specify what type of data is consumed by this endpoint.
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:13:56,000 --> 00:14:04,000
|
| 627 |
+
You can declare the JSON point, consumes application form data and in this case you don't need to use
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:14:04,000 --> 00:14:06,000
|
| 631 |
+
request param annotation.
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:14:06,000 --> 00:14:09,000
|
| 635 |
+
You need to use request body annotation.
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:14:10,000 --> 00:14:16,000
|
| 639 |
+
This annotation will help you to inject key value pairs into multi-value map object.
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:14:16,000 --> 00:14:24,000
|
| 643 |
+
Also, in case one parameter has multiple values, you can map values into the list like you can see
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:14:24,000 --> 00:14:26,000
|
| 647 |
+
in the following example.
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:14:26,000 --> 00:14:31,000
|
| 651 |
+
You can see in the command lines that this can be applied to the cases.
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:14:31,000 --> 00:14:37,000
|
| 655 |
+
When you have list of the separate parameters or just comma separated values.
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:14:38,000 --> 00:14:42,000
|
| 659 |
+
There is also an option to specify default value for the request param.
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:14:43,000 --> 00:14:49,000
|
| 663 |
+
I encourage you to look through the source code of the annotation and read attribute names.
|
| 664 |
+
|
| 665 |
+
167
|
| 666 |
+
00:14:49,000 --> 00:14:54,000
|
| 667 |
+
In most cases they are self describing requisite default value, for example.
|
| 668 |
+
|
| 669 |
+
168
|
| 670 |
+
00:14:54,000 --> 00:15:01,000
|
| 671 |
+
And even in case you have any questions, please feel free to post your questions below the video and
|
| 672 |
+
|
| 673 |
+
169
|
| 674 |
+
00:15:01,000 --> 00:15:03,000
|
| 675 |
+
I will be happy to answer.
|
| 676 |
+
|
| 677 |
+
170
|
| 678 |
+
00:15:03,000 --> 00:15:08,000
|
| 679 |
+
Let's learn now how to use response status in Spring MVC.
|
| 680 |
+
|
| 681 |
+
171
|
| 682 |
+
00:15:08,000 --> 00:15:15,000
|
| 683 |
+
You have opportunity to set the status code of an HTTP response if you want to set response status of
|
| 684 |
+
|
| 685 |
+
172
|
| 686 |
+
00:15:15,000 --> 00:15:16,000
|
| 687 |
+
your controller method.
|
| 688 |
+
|
| 689 |
+
173
|
| 690 |
+
00:15:17,000 --> 00:15:24,000
|
| 691 |
+
You can just use annotation response status over the method like you can see in this example.
|
| 692 |
+
|
| 693 |
+
174
|
| 694 |
+
00:15:24,000 --> 00:15:31,000
|
| 695 |
+
You may need to set up different statuses based on the defined and agreed contract.
|
| 696 |
+
|
| 697 |
+
175
|
| 698 |
+
00:15:31,000 --> 00:15:36,000
|
| 699 |
+
You can use response status just with HTTP status code.
|
| 700 |
+
|
| 701 |
+
176
|
| 702 |
+
00:15:36,000 --> 00:15:39,000
|
| 703 |
+
Or you can also specify the reason.
|
| 704 |
+
|
| 705 |
+
177
|
| 706 |
+
00:15:40,000 --> 00:15:44,000
|
| 707 |
+
Reason will be specified as a separate message in the response.
|
| 708 |
+
|
| 709 |
+
178
|
| 710 |
+
00:15:44,000 --> 00:15:46,000
|
| 711 |
+
Here you can see an example.
|
| 712 |
+
|
| 713 |
+
179
|
| 714 |
+
00:15:46,000 --> 00:15:51,000
|
| 715 |
+
In this case I return I'm a post response status.
|
| 716 |
+
|
| 717 |
+
180
|
| 718 |
+
00:15:51,000 --> 00:15:56,000
|
| 719 |
+
This response status is equivalent to the 418 status code.
|
| 720 |
+
|
| 721 |
+
181
|
| 722 |
+
00:15:57,000 --> 00:15:59,000
|
| 723 |
+
The HTTP 418.
|
| 724 |
+
|
| 725 |
+
182
|
| 726 |
+
00:15:59,000 --> 00:16:00,000
|
| 727 |
+
I'm a teapot.
|
| 728 |
+
|
| 729 |
+
183
|
| 730 |
+
00:16:00,000 --> 00:16:08,000
|
| 731 |
+
Client error response code indicates that the server refuses to brew coffee because it is permanently
|
| 732 |
+
|
| 733 |
+
184
|
| 734 |
+
00:16:08,000 --> 00:16:09,000
|
| 735 |
+
teapot.
|
| 736 |
+
|
| 737 |
+
185
|
| 738 |
+
00:16:10,000 --> 00:16:10,000
|
| 739 |
+
Yes.
|
| 740 |
+
|
| 741 |
+
186
|
| 742 |
+
00:16:10,000 --> 00:16:12,000
|
| 743 |
+
This is an interesting joke.
|
| 744 |
+
|
| 745 |
+
187
|
| 746 |
+
00:16:13,000 --> 00:16:21,000
|
| 747 |
+
This error message was designed as a one of the April Fools jokes, and the error states that any teapot
|
| 748 |
+
|
| 749 |
+
188
|
| 750 |
+
00:16:21,000 --> 00:16:26,000
|
| 751 |
+
that has been asked to brew coffee shall respond with this message.
|
| 752 |
+
|
| 753 |
+
189
|
| 754 |
+
00:16:27,000 --> 00:16:31,000
|
| 755 |
+
Funnily enough, also the status code is not used.
|
| 756 |
+
|
| 757 |
+
190
|
| 758 |
+
00:16:31,000 --> 00:16:34,000
|
| 759 |
+
It is supported by many HTTP libraries.
|
| 760 |
+
|
| 761 |
+
191
|
| 762 |
+
00:16:34,000 --> 00:16:42,000
|
| 763 |
+
Some time ago there was an effort to have this error removed so that the number can be used in an official
|
| 764 |
+
|
| 765 |
+
192
|
| 766 |
+
00:16:42,000 --> 00:16:43,000
|
| 767 |
+
capacity.
|
| 768 |
+
|
| 769 |
+
193
|
| 770 |
+
00:16:43,000 --> 00:16:52,000
|
| 771 |
+
However, this was met with a resistance and led to the creation of the SAFE 418 initiative.
|
| 772 |
+
|
| 773 |
+
194
|
| 774 |
+
00:16:52,000 --> 00:16:56,000
|
| 775 |
+
As such, the message and status code remain.
|
| 776 |
+
|
| 777 |
+
195
|
| 778 |
+
00:16:56,000 --> 00:17:03,000
|
| 779 |
+
Also, you can specify HTTP status as a return type if you wish, and after processing the request,
|
| 780 |
+
|
| 781 |
+
196
|
| 782 |
+
00:17:03,000 --> 00:17:05,000
|
| 783 |
+
you can return the status.
|
| 784 |
+
|
| 785 |
+
197
|
| 786 |
+
00:17:05,000 --> 00:17:13,000
|
| 787 |
+
For example, when we delete user, there is no resource that we can return after sending the request,
|
| 788 |
+
|
| 789 |
+
198
|
| 790 |
+
00:17:13,000 --> 00:17:20,000
|
| 791 |
+
we via delete method to user's resource and return no content status but attention.
|
| 792 |
+
|
| 793 |
+
199
|
| 794 |
+
00:17:21,000 --> 00:17:29,000
|
| 795 |
+
In this case it will be returned as message body because response status code will actually be 200.
|
| 796 |
+
|
| 797 |
+
200
|
| 798 |
+
00:17:30,000 --> 00:17:31,000
|
| 799 |
+
Be attentive with that.
|
| 800 |
+
|
| 801 |
+
201
|
| 802 |
+
00:17:32,000 --> 00:17:38,000
|
| 803 |
+
If we want to have different status code in response, you need to use response status annotation.
|
| 804 |
+
|
| 805 |
+
202
|
| 806 |
+
00:17:39,000 --> 00:17:47,000
|
| 807 |
+
In case user has been successfully created and inserted, I send confirmation create it will be returned
|
| 808 |
+
|
| 809 |
+
203
|
| 810 |
+
00:17:47,000 --> 00:17:48,000
|
| 811 |
+
in response body.
|
| 812 |
+
|
| 813 |
+
204
|
| 814 |
+
00:17:49,000 --> 00:17:55,000
|
| 815 |
+
When I send request was put method to update the resource and in case the resource has been updated,
|
| 816 |
+
|
| 817 |
+
205
|
| 818 |
+
00:17:56,000 --> 00:17:58,000
|
| 819 |
+
return accepted status.
|
| 820 |
+
|
| 821 |
+
206
|
| 822 |
+
00:17:59,000 --> 00:18:02,000
|
| 823 |
+
But what to do in case I need more flexibility?
|
| 824 |
+
|
| 825 |
+
207
|
| 826 |
+
00:18:02,000 --> 00:18:10,000
|
| 827 |
+
And like in this case I want to identify what response status to return during the execution.
|
| 828 |
+
|
| 829 |
+
208
|
| 830 |
+
00:18:10,000 --> 00:18:11,000
|
| 831 |
+
And not always.
|
| 832 |
+
|
| 833 |
+
209
|
| 834 |
+
00:18:11,000 --> 00:18:16,000
|
| 835 |
+
I can specify it in the annotation before methods gets executed.
|
| 836 |
+
|
| 837 |
+
210
|
| 838 |
+
00:18:16,000 --> 00:18:18,000
|
| 839 |
+
There are different workarounds that you can apply.
|
| 840 |
+
|
| 841 |
+
211
|
| 842 |
+
00:18:18,000 --> 00:18:23,000
|
| 843 |
+
One of them is to work with the HTTP response object directly.
|
| 844 |
+
|
| 845 |
+
212
|
| 846 |
+
00:18:23,000 --> 00:18:26,000
|
| 847 |
+
Another one is to use response entity.
|
| 848 |
+
|
| 849 |
+
213
|
| 850 |
+
00:18:26,000 --> 00:18:30,000
|
| 851 |
+
So let's learn how to work with the response entity object.
|
| 852 |
+
|
| 853 |
+
214
|
| 854 |
+
00:18:31,000 --> 00:18:37,000
|
| 855 |
+
If you are familiar with Spring framework, then you know that there are different ways of how you can
|
| 856 |
+
|
| 857 |
+
215
|
| 858 |
+
00:18:37,000 --> 00:18:39,000
|
| 859 |
+
achieve the same result in spring.
|
| 860 |
+
|
| 861 |
+
216
|
| 862 |
+
00:18:39,000 --> 00:18:43,000
|
| 863 |
+
The similar story is here you have different options.
|
| 864 |
+
|
| 865 |
+
217
|
| 866 |
+
00:18:43,000 --> 00:18:45,000
|
| 867 |
+
How to tune your HTTP response.
|
| 868 |
+
|
| 869 |
+
218
|
| 870 |
+
00:18:45,000 --> 00:18:51,000
|
| 871 |
+
And I prepared examples for you to show how you can tune HTTP response via response.
|
| 872 |
+
|
| 873 |
+
219
|
| 874 |
+
00:18:51,000 --> 00:19:00,000
|
| 875 |
+
Entity response Entity is a type to represent the whole HTTP response, including status code headers
|
| 876 |
+
|
| 877 |
+
220
|
| 878 |
+
00:19:00,000 --> 00:19:01,000
|
| 879 |
+
and response body.
|
| 880 |
+
|
| 881 |
+
221
|
| 882 |
+
00:19:02,000 --> 00:19:04,000
|
| 883 |
+
Do you use response entity?
|
| 884 |
+
|
| 885 |
+
222
|
| 886 |
+
00:19:04,000 --> 00:19:11,000
|
| 887 |
+
You need to declare it as return type of your method and spring will take the rest with regards to processing
|
| 888 |
+
|
| 889 |
+
223
|
| 890 |
+
00:19:11,000 --> 00:19:14,000
|
| 891 |
+
this object and preparing the response.
|
| 892 |
+
|
| 893 |
+
224
|
| 894 |
+
00:19:15,000 --> 00:19:17,000
|
| 895 |
+
Let's look at examples.
|
| 896 |
+
|
| 897 |
+
225
|
| 898 |
+
00:19:17,000 --> 00:19:22,000
|
| 899 |
+
In the first example you can see that I set return type as response entity.
|
| 900 |
+
|
| 901 |
+
226
|
| 902 |
+
00:19:22,000 --> 00:19:31,000
|
| 903 |
+
Important thing is that there are builders that you can use to build response entity to static masses
|
| 904 |
+
|
| 905 |
+
227
|
| 906 |
+
00:19:31,000 --> 00:19:38,000
|
| 907 |
+
will return object of header builder type and four methods will return object of body builder type.
|
| 908 |
+
|
| 909 |
+
228
|
| 910 |
+
00:19:38,000 --> 00:19:41,000
|
| 911 |
+
Body builder extends header builder.
|
| 912 |
+
|
| 913 |
+
229
|
| 914 |
+
00:19:41,000 --> 00:19:50,000
|
| 915 |
+
In this example I invoke okay method and they use body builder to create response entity with the header
|
| 916 |
+
|
| 917 |
+
230
|
| 918 |
+
00:19:50,000 --> 00:19:55,000
|
| 919 |
+
method I can specify header with the body mass that I can specify body.
|
| 920 |
+
|
| 921 |
+
231
|
| 922 |
+
00:19:55,000 --> 00:20:01,000
|
| 923 |
+
I believe everything is clear and there is no need in the additional explanation because methods are
|
| 924 |
+
|
| 925 |
+
232
|
| 926 |
+
00:20:01,000 --> 00:20:02,000
|
| 927 |
+
self-describing.
|
| 928 |
+
|
| 929 |
+
233
|
| 930 |
+
00:20:03,000 --> 00:20:10,000
|
| 931 |
+
And of course remember that in case something is not clear to you, you can always ask your questions
|
| 932 |
+
|
| 933 |
+
234
|
| 934 |
+
00:20:10,000 --> 00:20:14,000
|
| 935 |
+
below the video in comments and I will be happy to answer.
|
| 936 |
+
|
| 937 |
+
235
|
| 938 |
+
00:20:15,000 --> 00:20:18,000
|
| 939 |
+
There is also another way to create response entity.
|
| 940 |
+
|
| 941 |
+
236
|
| 942 |
+
00:20:18,000 --> 00:20:21,000
|
| 943 |
+
You can see commanded lines here.
|
| 944 |
+
|
| 945 |
+
237
|
| 946 |
+
00:20:21,000 --> 00:20:26,000
|
| 947 |
+
Basically you can create response entity object with a new keyword.
|
| 948 |
+
|
| 949 |
+
238
|
| 950 |
+
00:20:26,000 --> 00:20:34,000
|
| 951 |
+
In this particular example, I created headers and then I created Object of the Response entity type
|
| 952 |
+
|
| 953 |
+
239
|
| 954 |
+
00:20:34,000 --> 00:20:40,000
|
| 955 |
+
using constructor with response body headers and HTTP status.
|
| 956 |
+
|
| 957 |
+
240
|
| 958 |
+
00:20:40,000 --> 00:20:46,000
|
| 959 |
+
You can check the source code and make sure that there are different constructors that you can use to
|
| 960 |
+
|
| 961 |
+
241
|
| 962 |
+
00:20:46,000 --> 00:20:49,000
|
| 963 |
+
create response entity object.
|
| 964 |
+
|
| 965 |
+
242
|
| 966 |
+
00:20:49,000 --> 00:20:56,000
|
| 967 |
+
And the last but not the least for today, let's learn how to read HTTP headers in rest controller.
|
| 968 |
+
|
| 969 |
+
243
|
| 970 |
+
00:20:56,000 --> 00:21:03,000
|
| 971 |
+
You can use request header annotation to read headers individually as well as all together.
|
| 972 |
+
|
| 973 |
+
244
|
| 974 |
+
00:21:04,000 --> 00:21:11,000
|
| 975 |
+
In the first example here you can see how I put request header annotation before the parameter.
|
| 976 |
+
|
| 977 |
+
245
|
| 978 |
+
00:21:11,000 --> 00:21:14,000
|
| 979 |
+
I believe you already know how this will work.
|
| 980 |
+
|
| 981 |
+
246
|
| 982 |
+
00:21:14,000 --> 00:21:20,000
|
| 983 |
+
Spring will take care of injecting the request header value into the parameter.
|
| 984 |
+
|
| 985 |
+
247
|
| 986 |
+
00:21:20,000 --> 00:21:25,000
|
| 987 |
+
Basically you just need to specify which request header you want to parse.
|
| 988 |
+
|
| 989 |
+
248
|
| 990 |
+
00:21:26,000 --> 00:21:32,000
|
| 991 |
+
You can use one of the constants of the HTTP headers like you can see in this example.
|
| 992 |
+
|
| 993 |
+
249
|
| 994 |
+
00:21:33,000 --> 00:21:35,000
|
| 995 |
+
Basically that will be enough.
|
| 996 |
+
|
| 997 |
+
250
|
| 998 |
+
00:21:35,000 --> 00:21:43,000
|
| 999 |
+
Optionally, you can use required attribute to specify whether this request header is required or no
|
| 1000 |
+
|
| 1001 |
+
251
|
| 1002 |
+
00:21:43,000 --> 00:21:51,000
|
| 1003 |
+
default is set to true, which causes an exception in case such header is absent.
|
| 1004 |
+
|
| 1005 |
+
252
|
| 1006 |
+
00:21:51,000 --> 00:21:54,000
|
| 1007 |
+
Alternatively, you can provide a default value.
|
| 1008 |
+
|
| 1009 |
+
253
|
| 1010 |
+
00:21:55,000 --> 00:22:02,000
|
| 1011 |
+
In this case, you will not receive exception because of missing value due to the default value is there.
|
| 1012 |
+
|
| 1013 |
+
254
|
| 1014 |
+
00:22:02,000 --> 00:22:09,000
|
| 1015 |
+
In the second example you can see how I use request header annotation with the map parameter.
|
| 1016 |
+
|
| 1017 |
+
255
|
| 1018 |
+
00:22:09,000 --> 00:22:17,000
|
| 1019 |
+
This will lead us to reading of all request headers and inject all the values into the map together
|
| 1020 |
+
|
| 1021 |
+
256
|
| 1022 |
+
00:22:17,000 --> 00:22:19,000
|
| 1023 |
+
with the request headers names.
|
| 1024 |
+
|
| 1025 |
+
257
|
| 1026 |
+
00:22:19,000 --> 00:22:27,000
|
| 1027 |
+
In this particular example, I just iterate over all headers and brings them to console and in response
|
| 1028 |
+
|
| 1029 |
+
258
|
| 1030 |
+
00:22:27,000 --> 00:22:29,000
|
| 1031 |
+
I return total amount of headers.
|
| 1032 |
+
|
| 1033 |
+
259
|
| 1034 |
+
00:22:30,000 --> 00:22:31,000
|
| 1035 |
+
That's it.
|
| 1036 |
+
|
| 1037 |
+
260
|
| 1038 |
+
00:22:31,000 --> 00:22:37,000
|
| 1039 |
+
We learned a lot today and created our restful service with Spring MVC.
|
| 1040 |
+
|
| 1041 |
+
261
|
| 1042 |
+
00:22:37,000 --> 00:22:44,000
|
| 1043 |
+
We still have to learn how to test our restful service, but I would keep this topic for our next lesson,
|
| 1044 |
+
|
| 1045 |
+
262
|
| 1046 |
+
00:22:44,000 --> 00:22:46,000
|
| 1047 |
+
so stay tuned.
|
| 1048 |
+
|
| 1049 |
+
263
|
| 1050 |
+
00:22:47,000 --> 00:22:51,000
|
| 1051 |
+
And now let's recap what we have learned in the lesson.
|
| 1052 |
+
|
| 1053 |
+
264
|
| 1054 |
+
00:22:51,000 --> 00:22:56,000
|
| 1055 |
+
In this lesson, we learned how to create restful service with Spring MVC.
|
| 1056 |
+
|
| 1057 |
+
265
|
| 1058 |
+
00:22:57,000 --> 00:23:00,000
|
| 1059 |
+
We learned and configured all required dependencies.
|
| 1060 |
+
|
| 1061 |
+
266
|
| 1062 |
+
00:23:00,000 --> 00:23:06,000
|
| 1063 |
+
Now you know the difference between rest controller and controller annotations in spring.
|
| 1064 |
+
|
| 1065 |
+
267
|
| 1066 |
+
00:23:07,000 --> 00:23:14,000
|
| 1067 |
+
I explained you what the response body annotation is among other annotations and configurations that
|
| 1068 |
+
|
| 1069 |
+
268
|
| 1070 |
+
00:23:14,000 --> 00:23:16,000
|
| 1071 |
+
we learned during the lesson.
|
| 1072 |
+
|
| 1073 |
+
269
|
| 1074 |
+
00:23:16,000 --> 00:23:24,000
|
| 1075 |
+
It is worth to mention request body pass, variable request param response status response entity and
|
| 1076 |
+
|
| 1077 |
+
270
|
| 1078 |
+
00:23:24,000 --> 00:23:29,000
|
| 1079 |
+
request header to read http headers in rest controller.
|
| 1080 |
+
|
| 1081 |
+
271
|
| 1082 |
+
00:23:29,000 --> 00:23:31,000
|
| 1083 |
+
That's all for today.
|
| 1084 |
+
|
| 1085 |
+
272
|
| 1086 |
+
00:23:31,000 --> 00:23:33,000
|
| 1087 |
+
Thanks a lot for your attention.
|
| 1088 |
+
|
| 1089 |
+
273
|
| 1090 |
+
00:23:33,000 --> 00:23:36,000
|
| 1091 |
+
Have a great day and see you in the next lesson.
|
| 1092 |
+
|
91 - REST Architecture/003 Source-code-of-examples-commit-with-changes-.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/5f6b4f695bb88865978fb7cbe622855783c17cfa
|
91 - REST Architecture/004 Review of tools for API testing & Postman Installation_en.srt
ADDED
|
@@ -0,0 +1,664 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:05,000 --> 00:00:06,000
|
| 3 |
+
Hello team.
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:06,000 --> 00:00:11,000
|
| 7 |
+
In this video lesson, we are going to make an overview of the tools for testing.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:12,000 --> 00:00:19,000
|
| 11 |
+
I believe that this will give you directions for further learning and you will understand what you need
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:19,000 --> 00:00:22,000
|
| 15 |
+
and what to suit your needs is the best.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:23,000 --> 00:00:29,000
|
| 19 |
+
During the review of the API testing tools, I will make a short overview of soap messaging protocol
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:29,000 --> 00:00:33,000
|
| 23 |
+
and tools for testing web services that use soap.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:34,000 --> 00:00:39,000
|
| 27 |
+
I will focus your attention on the three very popular tools for testing.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:39,000 --> 00:00:44,000
|
| 31 |
+
They are Postman, Fiddler and Wireshark.
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:44,000 --> 00:00:49,000
|
| 35 |
+
We will compare them between each other and the remaining part of the lesson.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:49,000 --> 00:00:54,000
|
| 39 |
+
We are going to talk about postman comparison of desktop and web version.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:54,000 --> 00:01:00,000
|
| 43 |
+
By the end of this lesson you are going to have postman installed on your computer and you will be prepared
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:01:00,000 --> 00:01:01,000
|
| 47 |
+
for the following lessons.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:01:01,000 --> 00:01:03,000
|
| 51 |
+
Let's start our lesson.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:01:04,000 --> 00:01:07,000
|
| 55 |
+
Let's review tools for API testing.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:01:07,000 --> 00:01:10,000
|
| 59 |
+
There are several tools available for API testing.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:01:10,000 --> 00:01:12,000
|
| 63 |
+
Here are some popular ones.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:01:13,000 --> 00:01:14,000
|
| 67 |
+
Postman.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:01:14,000 --> 00:01:21,000
|
| 71 |
+
Postman is a popular tool for API testing that allows you to send requests and analyze responses in
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:01:21,000 --> 00:01:23,000
|
| 75 |
+
a user friendly interface.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:01:23,000 --> 00:01:29,000
|
| 79 |
+
We are going to talk about it more in this video and in the following ones.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:01:29,000 --> 00:01:30,000
|
| 83 |
+
Fiddler.
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:01:30,000 --> 00:01:35,000
|
| 87 |
+
It is indeed another popular tool for testing and debugging.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:01:35,000 --> 00:01:43,000
|
| 91 |
+
Particularly for analyzing and manipulating http https traffic between a client and the server.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:01:43,000 --> 00:01:50,000
|
| 95 |
+
It offers features like request interception, debugging, and performance testing.
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:01:51,000 --> 00:01:56,000
|
| 99 |
+
Wireshark is another popular tool that can be used for testing and debugging.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:01:56,000 --> 00:02:04,000
|
| 103 |
+
It is a network protocol analyzer that captures and displays network packets in real time, allowing
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:02:04,000 --> 00:02:10,000
|
| 107 |
+
you to inspect the details of the packets exchanged between the client and the server.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:02:10,000 --> 00:02:18,000
|
| 111 |
+
While Wireshark may not be specialized for API testing as some of other tools I mentioned earlier,
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:02:18,000 --> 00:02:27,000
|
| 115 |
+
it can still be a useful tool for troubleshooting and diagnosing network related issues in communication.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:02:27,000 --> 00:02:35,000
|
| 119 |
+
So in addition to the tools I mentioned earlier, Wireshark is also a valuable tool for testing and
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:02:35,000 --> 00:02:36,000
|
| 123 |
+
debugging.
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:02:37,000 --> 00:02:38,000
|
| 127 |
+
Swap UI.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:02:38,000 --> 00:02:47,000
|
| 131 |
+
Swap UI is an open source API testing tool that allows you to create and run automated functional regression
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:02:47,000 --> 00:02:51,000
|
| 135 |
+
compliance and load tests for rest and soap APIs.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:02:51,000 --> 00:02:54,000
|
| 139 |
+
But what is soap?
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:02:54,000 --> 00:02:58,000
|
| 143 |
+
Soap stands for Simple Object Access Protocol.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:02:58,000 --> 00:03:04,000
|
| 147 |
+
It is a messaging protocol that is used to exchange structure data between different applications over
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:03:04,000 --> 00:03:05,000
|
| 151 |
+
the Internet.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:03:05,000 --> 00:03:15,000
|
| 155 |
+
It relies on XML as its message format and is typically used in web services to send requests and receive
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:03:15,000 --> 00:03:16,000
|
| 159 |
+
responses.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:03:17,000 --> 00:03:23,000
|
| 163 |
+
Soap is a tool used for testing and developing web services that use soap.
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:03:24,000 --> 00:03:25,000
|
| 167 |
+
Insomnia.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:03:25,000 --> 00:03:34,000
|
| 171 |
+
Insomnia is a free and open source rest client that enables you to send HTTP requests and user response
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:03:34,000 --> 00:03:36,000
|
| 175 |
+
in a user friendly interface.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:03:37,000 --> 00:03:38,000
|
| 179 |
+
G matter.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:03:38,000 --> 00:03:45,000
|
| 183 |
+
Apache G matter is a popular open source tool for load testing and performance measurement of APIs,
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:03:45,000 --> 00:03:48,000
|
| 187 |
+
web applications and other services.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:03:49,000 --> 00:03:49,000
|
| 191 |
+
You, man.
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:03:50,000 --> 00:03:56,000
|
| 195 |
+
It is a common line tools that allows you to run and test postman collections from the command line,
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:03:56,000 --> 00:04:02,000
|
| 199 |
+
making it a Gil for automated testing and integration with CI CD pipelines.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:04:03,000 --> 00:04:09,000
|
| 203 |
+
Rest assured it is a Java based library for testing restful APIs.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:04:09,000 --> 00:04:17,000
|
| 207 |
+
It allows you to write tests in Java and provides built in support for various HTTP methods, authentication
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:04:17,000 --> 00:04:19,000
|
| 211 |
+
and response validation.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:04:20,000 --> 00:04:25,000
|
| 215 |
+
These are just few examples of the many tools available for API testing.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:04:25,000 --> 00:04:32,000
|
| 219 |
+
The choice of tool will depend on your specific needs, preferences and technical expertise.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:04:33,000 --> 00:04:39,000
|
| 223 |
+
All eight tools that I mentioned on the previous slide are really popular ones, but I would like to
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:04:39,000 --> 00:04:42,000
|
| 227 |
+
draw your attention to three out of them.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:04:42,000 --> 00:04:46,000
|
| 231 |
+
They are Postman, fiddler and Wireshark.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:04:47,000 --> 00:04:54,000
|
| 235 |
+
I can't say that these tools are better than other API testing and debugging tools as the suitability
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:04:54,000 --> 00:04:58,000
|
| 239 |
+
of a particular tool will depend on your specific needs and preferences.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:04:58,000 --> 00:05:06,000
|
| 243 |
+
However, these tools are widely used and have some advantages that make them popular choices among
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:05:06,000 --> 00:05:08,000
|
| 247 |
+
developers and testers.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:05:08,000 --> 00:05:11,000
|
| 251 |
+
Postman is user friendly tools.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:05:11,000 --> 00:05:17,000
|
| 255 |
+
It provides a graphical user interface for creating testing and documenting APIs.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:05:17,000 --> 00:05:25,000
|
| 259 |
+
It supports a wide range of HTTP methods and formats and provides features like automatic request generation.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:05:25,000 --> 00:05:27,000
|
| 263 |
+
Code snippets and request history.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:05:28,000 --> 00:05:35,000
|
| 267 |
+
It is also used for easy collaboration with team members and integrates well with other tools in the
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:05:35,000 --> 00:05:37,000
|
| 271 |
+
API development workflow.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:05:37,000 --> 00:05:41,000
|
| 275 |
+
Fiddler is a powerful web debugging proxy.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:05:41,000 --> 00:05:49,000
|
| 279 |
+
It can also be used to simulate network conditions such as low bandwidth or high latency.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:05:49,000 --> 00:05:58,000
|
| 283 |
+
To test the behavior of APIs under different network conditions, Wireshark is a network protocol analyzer.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:05:58,000 --> 00:06:06,000
|
| 287 |
+
It is often used to diagnose and troubleshoot network related issues and can be a valuable tool in identifying
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:06:06,000 --> 00:06:08,000
|
| 291 |
+
and resolving issues.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:06:09,000 --> 00:06:15,000
|
| 295 |
+
Overall, the choice of tool will depend on the specific requirements of your API.
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:06:15,000 --> 00:06:21,000
|
| 299 |
+
Testing and debugging tasks, as well as your personal preferences and experience.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:06:21,000 --> 00:06:26,000
|
| 303 |
+
All three tools used for debugging and testing network traffic.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:06:26,000 --> 00:06:32,000
|
| 307 |
+
Postman is an HTTP client that allows you to send HTTP requests and receive responses.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:06:32,000 --> 00:06:40,000
|
| 311 |
+
Fiddler is a web debugging proxy that captures and analyzes HTTP traffic between your computer and the
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:06:40,000 --> 00:06:41,000
|
| 315 |
+
Internet.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:06:41,000 --> 00:06:48,000
|
| 319 |
+
And Wireshark is a network protocol analyzer that captures and displays network packets in real time.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:06:48,000 --> 00:06:50,000
|
| 323 |
+
That is a short summary.
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:06:50,000 --> 00:06:57,000
|
| 327 |
+
So let's talk about Postman right now, because it is the most popular tool in my opinion.
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:06:58,000 --> 00:07:03,000
|
| 331 |
+
As you already learned from the agenda today, we are going to talk about Postman.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:07:04,000 --> 00:07:09,000
|
| 335 |
+
I already told you on the high level about this tool during the review of previous slides.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:07:09,000 --> 00:07:16,000
|
| 339 |
+
In my opinion, Postman is tool number one that should be installed on your computer if you develop
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:07:16,000 --> 00:07:16,000
|
| 343 |
+
for web.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:07:17,000 --> 00:07:24,000
|
| 347 |
+
It is relatively lightweight, it is super intuitive and you are going to see that it wouldn't take
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:07:24,000 --> 00:07:31,000
|
| 351 |
+
too much time of yours to understand the interface and this is a huge advantage.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:07:31,000 --> 00:07:36,000
|
| 355 |
+
Let's learn this tool better to learn postman tool better.
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:07:36,000 --> 00:07:39,000
|
| 359 |
+
Let's learn key components of this tool.
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:07:39,000 --> 00:07:42,000
|
| 363 |
+
They are request builder.
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:07:42,000 --> 00:07:49,000
|
| 367 |
+
Postman provides a user friendly interface for creating HTTP requests, allowing you to specify parameters
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:07:49,000 --> 00:07:55,000
|
| 371 |
+
like HTTP method, URL headers and body response view.
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:07:56,000 --> 00:08:02,000
|
| 375 |
+
Explore the response Status Code Size Response Time Headers Response Body.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:08:03,000 --> 00:08:04,000
|
| 379 |
+
Collection.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:08:04,000 --> 00:08:11,000
|
| 383 |
+
A collection in Postman is a group of related requests that can be organized and saved together.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:08:11,000 --> 00:08:18,000
|
| 387 |
+
It allows you to group and organize your requests for easier management and sharing with others.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:08:18,000 --> 00:08:20,000
|
| 391 |
+
Environment.
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:08:20,000 --> 00:08:26,000
|
| 395 |
+
An environment in Postman allows you to configure variables that can be used across multiple requests.
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:08:27,000 --> 00:08:35,000
|
| 399 |
+
This feature can be used to specify things like server URLs, authentication tokens or other parameters
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:08:35,000 --> 00:08:38,000
|
| 403 |
+
that may change based on the environment.
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:08:40,000 --> 00:08:41,000
|
| 407 |
+
Test scripts.
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:08:41,000 --> 00:08:48,000
|
| 411 |
+
Postman provides a scripting feature that allows you to write JavaScript code to automate tasks, customize
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:08:48,000 --> 00:08:52,000
|
| 415 |
+
requests, and perform assertions on responses.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:08:52,000 --> 00:08:56,000
|
| 419 |
+
Test scripts can be used to validate the response data.
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:08:56,000 --> 00:09:01,000
|
| 423 |
+
Automate test cases and perform other custom operations.
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:09:02,000 --> 00:09:02,000
|
| 427 |
+
Runner.
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:09:03,000 --> 00:09:09,000
|
| 431 |
+
The postman runner allows it to execute a collection of requests automatically and generate reports.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:09:09,000 --> 00:09:16,000
|
| 435 |
+
It can be used for testing APIs, generating test reports and monitoring API performance.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:09:17,000 --> 00:09:18,000
|
| 439 |
+
Integrations.
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:09:18,000 --> 00:09:26,000
|
| 443 |
+
Postman integrates with other tools in the API development workflow, such as Git, Jenkins and Swagger,
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:09:26,000 --> 00:09:30,000
|
| 447 |
+
allowing for easier collaboration and workflow management.
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:09:30,000 --> 00:09:39,000
|
| 451 |
+
Postman also offers several advanced features that help developers automate testing and improve productivity,
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:09:39,000 --> 00:09:43,000
|
| 455 |
+
such as the ability to write test scripts in JavaScript.
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:09:43,000 --> 00:09:48,000
|
| 459 |
+
Set environment variables and integrate with other development tools.
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:09:48,000 --> 00:09:56,000
|
| 463 |
+
Overall, Postman plays a crucial role in the development process by making it easier for developers
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:09:56,000 --> 00:09:58,000
|
| 467 |
+
to test and debug APIs.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:09:58,000 --> 00:10:05,000
|
| 471 |
+
Collaborate with team members and improve the overall quality and reliability of their APIs.
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:10:06,000 --> 00:10:10,000
|
| 475 |
+
Let's now install the postman on your laptop.
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:10:10,000 --> 00:10:14,000
|
| 479 |
+
I will provide you with step by step installation guide.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:10:14,000 --> 00:10:19,000
|
| 483 |
+
First of all, open a web browser and navigate to the Postman website.
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:10:20,000 --> 00:10:29,000
|
| 487 |
+
You can easily get navigated directly to the downloads page or find hyper references on the home page.
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:10:30,000 --> 00:10:36,000
|
| 491 |
+
Now you need to select whether you want to download desktop version or to use browser version.
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:10:36,000 --> 00:10:40,000
|
| 495 |
+
Each version has its own advantages and disadvantages.
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:10:40,000 --> 00:10:46,000
|
| 499 |
+
The desktop version of Postman is a standalone application that can be installed on your computer.
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:10:46,000 --> 00:10:52,000
|
| 503 |
+
It offers more features and customization options compared to the browser version.
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:10:52,000 --> 00:10:59,000
|
| 507 |
+
With the desktop version, you can create and manage collections of requests, write the scripts and
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:10:59,000 --> 00:11:05,000
|
| 511 |
+
collaborate with the team members using features like version control and shared workspaces.
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:11:05,000 --> 00:11:13,000
|
| 515 |
+
The desktop version also offers a more streamlined and faster user experience as it doesn't rely on
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:11:13,000 --> 00:11:14,000
|
| 519 |
+
a web browser.
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:11:15,000 --> 00:11:21,000
|
| 523 |
+
On the other hand, the browser version of Postman is a lightweight extension that can be installed
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:11:21,000 --> 00:11:23,000
|
| 527 |
+
directly in your web browser.
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:11:23,000 --> 00:11:31,000
|
| 531 |
+
It is a yield for quick testing and debugging of APIs as it doesn't require any installation or setup.
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:11:31,000 --> 00:11:38,000
|
| 535 |
+
The browser version is also useful for users who prefer to work within their web browser and do not
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:11:38,000 --> 00:11:41,000
|
| 539 |
+
want to switch between multiple applications.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:11:41,000 --> 00:11:46,000
|
| 543 |
+
However, it may have limited features compared to the desktop version.
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:11:47,000 --> 00:11:53,000
|
| 547 |
+
Ultimately, the choice between the desktop and browser version of Postman depends on your specific
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:11:53,000 --> 00:11:55,000
|
| 551 |
+
needs and preferences.
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:11:55,000 --> 00:12:03,000
|
| 555 |
+
If you need advanced features and customizations or you work with APIs, frequently, the desktop version
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:12:03,000 --> 00:12:05,000
|
| 559 |
+
may be a better fit.
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:12:05,000 --> 00:12:12,000
|
| 563 |
+
However, if you only need basic API testing capabilities or prefer to work within your web browser,
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:12:12,000 --> 00:12:16,000
|
| 567 |
+
the browser version may be more suitable.
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:12:16,000 --> 00:12:24,000
|
| 571 |
+
So I believe that we will go with desktop version for that just download installer by clicking the biggest
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:12:24,000 --> 00:12:26,000
|
| 575 |
+
button that you can see on the screen.
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:12:26,000 --> 00:12:33,000
|
| 579 |
+
It automatically detects that have Windows and it offers me to download installer for Windows.
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:12:33,000 --> 00:12:39,000
|
| 583 |
+
But in case you have other operating system, you can select another one below.
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:12:40,000 --> 00:12:47,000
|
| 587 |
+
Once the download is complete, locate the downloaded file in your downloads folder or wherever you
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:12:47,000 --> 00:12:50,000
|
| 591 |
+
saved it and just run installation file.
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:12:51,000 --> 00:12:55,000
|
| 595 |
+
What will happen after doesn't require explanation.
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:12:55,000 --> 00:13:02,000
|
| 599 |
+
Postman will be installed by default in the program files folder and will ask you nothing.
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:13:02,000 --> 00:13:04,000
|
| 603 |
+
Now you can launch it.
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:13:04,000 --> 00:13:11,000
|
| 607 |
+
When you launched it, you need to select whether you want to create an account and log in using credentials
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:13:11,000 --> 00:13:15,000
|
| 611 |
+
or you will continue without registration.
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:13:15,000 --> 00:13:20,000
|
| 615 |
+
Basically, you can click this link, skip, and go to the app and that's it.
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:13:21,000 --> 00:13:26,000
|
| 619 |
+
In the next lesson, I'm going to make practical exercises together with you, and I will do screen
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:13:26,000 --> 00:13:31,000
|
| 623 |
+
sharing to give you more practical experience of working with Postman.
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:13:31,000 --> 00:13:39,000
|
| 627 |
+
Together we'll test our Rest API that we created in the previous lesson, But now let's recap what we
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:13:39,000 --> 00:13:41,000
|
| 631 |
+
have learned in this video.
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:13:42,000 --> 00:13:46,000
|
| 635 |
+
Today we did an overview of tools for API testing.
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:13:46,000 --> 00:13:51,000
|
| 639 |
+
Now you know the difference between them and which one to choose.
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:13:51,000 --> 00:13:55,000
|
| 643 |
+
I explained you what a soap messaging protocol is.
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:13:55,000 --> 00:14:01,000
|
| 647 |
+
You know, such popular tools as Postman, Fiddler and Wireshark.
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:14:01,000 --> 00:14:07,000
|
| 651 |
+
We learned key components of Postman compared desktop and web version.
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:14:07,000 --> 00:14:12,000
|
| 655 |
+
And in the end of the lesson, we installed Postman desktop version on your computer.
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:14:12,000 --> 00:14:14,000
|
| 659 |
+
Thanks a lot for your attention.
|
| 660 |
+
|
| 661 |
+
166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and we installed Postman.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:15,000 --> 00:00:18,000
|
| 15 |
+
This all we did in previous lessons.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:18,000 --> 00:00:22,000
|
| 19 |
+
And now it is time to learn how we can test our API.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:23,000 --> 00:00:29,000
|
| 23 |
+
This is going to be less full of practical examples, so we'll start lesson directly from the screen
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:29,000 --> 00:00:30,000
|
| 27 |
+
sharing.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:30,000 --> 00:00:37,000
|
| 31 |
+
I'm going to make an overview of Postman interface and main UI elements that we are going to interact
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:37,000 --> 00:00:38,000
|
| 35 |
+
with.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:38,000 --> 00:00:45,000
|
| 39 |
+
Also, I'm going to share with you a collection of requests and I will show you how you can import those
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:45,000 --> 00:00:50,000
|
| 43 |
+
in your postman in order to repeat after me all my queries.
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:50,000 --> 00:00:56,000
|
| 47 |
+
I will show how to export existing collections or how to create new collections.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:57,000 --> 00:01:01,000
|
| 51 |
+
I'm going to show you how you can send requests with different methods.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:01:01,000 --> 00:01:03,000
|
| 55 |
+
We'll read response.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:01:03,000 --> 00:01:08,000
|
| 59 |
+
We are going to learn how to work with responses and how to analyze them.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:01:09,000 --> 00:01:14,000
|
| 63 |
+
Also, we'll learn how to send and read custom headers.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:01:14,000 --> 00:01:19,000
|
| 67 |
+
We'll perform testing of our restful service that we created in previous lesson.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:01:19,000 --> 00:01:23,000
|
| 71 |
+
So we'll test all endpoints that we created.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:01:24,000 --> 00:01:31,000
|
| 75 |
+
We'll test, create, read, update, delete operations with a resource using our rest API.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:01:32,000 --> 00:01:38,000
|
| 79 |
+
Also, I'm going to explain you the difference between form data and form URL encoded.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:01:38,000 --> 00:01:45,000
|
| 83 |
+
Let's start our lesson and from this point we can jump to the live demo and I will proceed with the
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:01:45,000 --> 00:01:46,000
|
| 87 |
+
screen sharing.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:01:46,000 --> 00:01:50,000
|
| 91 |
+
So here you can see Interface of the Postman.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:01:50,000 --> 00:01:55,000
|
| 95 |
+
Let me make a high level overview of the key UI elements here.
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:01:55,000 --> 00:02:00,000
|
| 99 |
+
And after that we will dive deeper in details of each section by using it.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:02:00,000 --> 00:02:07,000
|
| 103 |
+
As you may already see, the Postman desktop version has a clean and user friendly interface that is
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:02:07,000 --> 00:02:10,000
|
| 107 |
+
divided into several sections.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:02:10,000 --> 00:02:14,000
|
| 111 |
+
The main sections of the interface include sidebar.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:02:14,000 --> 00:02:22,000
|
| 115 |
+
The sidebar is located on the left hand side of the screen and provides access to all the features and
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:02:22,000 --> 00:02:24,000
|
| 119 |
+
functions in Postman.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:02:24,000 --> 00:02:33,000
|
| 123 |
+
It includes tabs for collections, APIs, environments, mock servers, monitors and history request
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:02:33,000 --> 00:02:34,000
|
| 127 |
+
builder.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:02:34,000 --> 00:02:41,000
|
| 131 |
+
The request builder is located in the center of the screen and allows you to create and send requests
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:02:41,000 --> 00:02:42,000
|
| 135 |
+
to APIs.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:02:42,000 --> 00:02:49,000
|
| 139 |
+
It includes fields for the request mask, URL, parameters, headers and body.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:02:50,000 --> 00:02:55,000
|
| 143 |
+
Also, in case endpoint requires authorization, you can configure it here too.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:02:55,000 --> 00:02:58,000
|
| 147 |
+
You can capture cookies.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:02:59,000 --> 00:03:00,000
|
| 151 |
+
Quote, pain.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:03:00,000 --> 00:03:03,000
|
| 155 |
+
Here on the right you can find really useful tool.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:03:03,000 --> 00:03:06,000
|
| 159 |
+
It is called code snippet.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:03:06,000 --> 00:03:14,000
|
| 163 |
+
Basically, you can generate the code to execute required query no matter what you want to use curl
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:03:14,000 --> 00:03:17,000
|
| 167 |
+
request or C-sharp or Java.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:03:17,000 --> 00:03:22,000
|
| 171 |
+
Just use this dropdown list to select what you need.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:03:22,000 --> 00:03:28,000
|
| 175 |
+
Later, you can use this code in your program in order to execute the query that you need.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:03:29,000 --> 00:03:30,000
|
| 179 |
+
Response.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:03:30,000 --> 00:03:32,000
|
| 183 |
+
Pain is a response.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:03:32,000 --> 00:03:39,000
|
| 187 |
+
Pain is located to the bottom of the request builder and displays the response data returned by the
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:03:39,000 --> 00:03:39,000
|
| 191 |
+
API.
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:03:40,000 --> 00:03:45,000
|
| 195 |
+
It includes tabs for the response body headers and cookies.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:03:45,000 --> 00:03:50,000
|
| 199 |
+
That's the place where we will observe what server responded us.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:03:50,000 --> 00:03:53,000
|
| 203 |
+
Test and console panes.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:03:53,000 --> 00:04:01,000
|
| 207 |
+
The test and console panes are located at the bottom of the screen and allow you to write and run tests
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:04:01,000 --> 00:04:03,000
|
| 211 |
+
for your API requests.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:04:03,000 --> 00:04:09,000
|
| 215 |
+
The console pane displays log messages and errors generated by postman.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:04:10,000 --> 00:04:11,000
|
| 219 |
+
Top bar.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:04:12,000 --> 00:04:18,000
|
| 223 |
+
The top bar is located at the very top of the screen and includes the work space management.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:04:19,000 --> 00:04:27,000
|
| 227 |
+
Also, you can create an account if you want to personalize your experience or use Postman without account.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:04:27,000 --> 00:04:28,000
|
| 231 |
+
It is up to you.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:04:29,000 --> 00:04:33,000
|
| 235 |
+
Also, you can use search bar and settings.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:04:33,000 --> 00:04:40,000
|
| 239 |
+
Overall, the possible interface is designed to be intuitive and user friendly, with key UI elements
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:04:40,000 --> 00:04:44,000
|
| 243 |
+
organized in a logical and easy to use manner.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:04:45,000 --> 00:04:48,000
|
| 247 |
+
So it is time to start using Postman.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:04:48,000 --> 00:04:54,000
|
| 251 |
+
For the sake of the demo, I started the web server and deployed the rest APIs that we developed together
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:04:54,000 --> 00:05:02,000
|
| 255 |
+
in the previous lesson to interact with user resource and more demo endpoints.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:05:02,000 --> 00:05:05,000
|
| 259 |
+
Make sure that your server is running.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:05:05,000 --> 00:05:10,000
|
| 263 |
+
And now I'm going to execute queries imitating the development process.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:05:11,000 --> 00:05:19,000
|
| 267 |
+
Usually during the development you design and point implement it and then you want to test how it works.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:05:19,000 --> 00:05:25,000
|
| 271 |
+
You just open the postman and send some queries and explore what is returned.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:05:26,000 --> 00:05:31,000
|
| 275 |
+
So now when we know the interface, we can start working with Postman.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:05:32,000 --> 00:05:40,000
|
| 279 |
+
In the previous lesson we created our rest API and now let's learn Postman better by actually working
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:05:40,000 --> 00:05:40,000
|
| 283 |
+
with it.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:05:40,000 --> 00:05:49,000
|
| 287 |
+
I will just imitate the regular flow that I would do as a developer or when I was supposed to test endpoints.
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:05:49,000 --> 00:05:54,000
|
| 291 |
+
Today I'm going to show you how to create your own collections of requests.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:05:55,000 --> 00:06:01,000
|
| 295 |
+
But before we start, I want to say that in attachments to this lesson, you are going to find the reference
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:06:01,000 --> 00:06:03,000
|
| 299 |
+
to the export of collections.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:06:03,000 --> 00:06:11,000
|
| 303 |
+
Basically, you can click import here and import my collections that I have shared in the attachments
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:06:11,000 --> 00:06:12,000
|
| 307 |
+
to this lesson.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:06:12,000 --> 00:06:18,000
|
| 311 |
+
You just need drag and drop my export file into the area inside your postman.
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:06:19,000 --> 00:06:27,000
|
| 315 |
+
Taking into account I already have such a collection, I would import it as a copy and after importing
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:06:27,000 --> 00:06:33,000
|
| 319 |
+
you are going to have the same list of requests that I'm going to review with you today.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:06:33,000 --> 00:06:39,000
|
| 323 |
+
Or you can just follow my examples and create your own collection as you wish.
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:06:39,000 --> 00:06:46,000
|
| 327 |
+
In case you want to export your collection, you can just find three dots here and click export.
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:06:46,000 --> 00:06:47,000
|
| 331 |
+
That's it.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:06:48,000 --> 00:06:50,000
|
| 335 |
+
Let's send our first request.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:06:51,000 --> 00:06:53,000
|
| 339 |
+
Everything is simple here.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:06:53,000 --> 00:06:59,000
|
| 343 |
+
You just paste the URL into query pane where I take this URL.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:06:59,000 --> 00:07:03,000
|
| 347 |
+
Well, I deployed my web application.
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:07:03,000 --> 00:07:08,000
|
| 351 |
+
It is available at localhost at default port 8080.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:07:08,000 --> 00:07:12,000
|
| 355 |
+
Our deployed application is called Spring Web.
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:07:12,000 --> 00:07:15,000
|
| 359 |
+
And then goes, name of my endpoint.
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:07:16,000 --> 00:07:18,000
|
| 363 |
+
Let me open the source code.
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:07:18,000 --> 00:07:19,000
|
| 367 |
+
Here it is.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:07:20,000 --> 00:07:21,000
|
| 371 |
+
Users.
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:07:21,000 --> 00:07:24,000
|
| 375 |
+
Let's get back to the postman.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:07:24,000 --> 00:07:29,000
|
| 379 |
+
Now we need to check which request method we are going to use to reach the resource.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:07:29,000 --> 00:07:36,000
|
| 383 |
+
By default, it is get method here, but you can use drop down to select the method that you need.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:07:37,000 --> 00:07:39,000
|
| 387 |
+
I'm ready to send the request.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:07:39,000 --> 00:07:43,000
|
| 391 |
+
I click send button and here is the response.
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:07:43,000 --> 00:07:46,000
|
| 395 |
+
Let's explore it together.
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:07:46,000 --> 00:07:50,000
|
| 399 |
+
This endpoint should return a collection of users.
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:07:50,000 --> 00:07:51,000
|
| 403 |
+
You can see 200.
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:07:51,000 --> 00:07:52,000
|
| 407 |
+
Okay.
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:07:52,000 --> 00:07:55,000
|
| 411 |
+
Status code time of response.
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:07:55,000 --> 00:07:57,000
|
| 415 |
+
Size of the response.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:07:58,000 --> 00:07:58,000
|
| 419 |
+
Here.
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:07:58,000 --> 00:08:05,000
|
| 423 |
+
You can also use navigation pane to explore is a body or cookies or headers.
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:08:05,000 --> 00:08:09,000
|
| 427 |
+
In this case there are no cookies, but there are some headers.
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:08:09,000 --> 00:08:14,000
|
| 431 |
+
You can explore the response in the pretty or raw format.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:08:14,000 --> 00:08:21,000
|
| 435 |
+
Usually it is hard to work with raw format because it is not readable with pretty format.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:08:21,000 --> 00:08:25,000
|
| 439 |
+
You can collapse and expand the elements of the response.
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:08:26,000 --> 00:08:29,000
|
| 443 |
+
The format of the response is auto detected.
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:08:29,000 --> 00:08:35,000
|
| 447 |
+
But in case you need to change the format of the response, you can use this dropdown.
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:08:35,000 --> 00:08:40,000
|
| 451 |
+
So in the response, you can see that I have multiple users here.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:08:41,000 --> 00:08:49,000
|
| 455 |
+
What you also would like to do usually is to store the request in order to not create the same request
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:08:49,000 --> 00:08:50,000
|
| 459 |
+
each time from scratch.
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:08:51,000 --> 00:08:53,000
|
| 463 |
+
So let's click Save Button.
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:08:54,000 --> 00:09:02,000
|
| 467 |
+
But taking into account that this request is already saved in my postman, let's use save as option.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:09:02,000 --> 00:09:06,000
|
| 471 |
+
Specify meaningful name for the query in order.
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:09:06,000 --> 00:09:09,000
|
| 475 |
+
You can easily understand what it is about.
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:09:10,000 --> 00:09:17,000
|
| 479 |
+
You can also add the description to the query if you want to be able to recall what it is about later.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:09:17,000 --> 00:09:21,000
|
| 483 |
+
Each request should be a part of some collection.
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:09:21,000 --> 00:09:25,000
|
| 487 |
+
You can see that I have collections here created already.
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:09:25,000 --> 00:09:33,000
|
| 491 |
+
You can create new collection by clicking new collection button or just select one of the existing collections
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:09:33,000 --> 00:09:35,000
|
| 495 |
+
in order to save the query.
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:09:36,000 --> 00:09:42,000
|
| 499 |
+
Inside the collection, you can create folders in case you want to group your queries in another way.
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:09:42,000 --> 00:09:48,000
|
| 503 |
+
Also, you can navigate between collections and folders using these breadcrumbs.
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:09:49,000 --> 00:09:50,000
|
| 507 |
+
Taking into account.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:09:50,000 --> 00:09:53,000
|
| 511 |
+
I have this query saved already.
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:09:53,000 --> 00:09:58,000
|
| 515 |
+
I would just click cancel button, but you can click save button.
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:09:58,000 --> 00:10:04,000
|
| 519 |
+
All your collections you can find in the left pane collections.
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:10:04,000 --> 00:10:09,000
|
| 523 |
+
Here they just double click on the request and you will open it.
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:10:10,000 --> 00:10:18,000
|
| 527 |
+
The next request is to fetch user by ID using the endpoint that we created in previous lesson I specify
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:10:18,000 --> 00:10:21,000
|
| 531 |
+
users end point and user ID.
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:10:22,000 --> 00:10:27,000
|
| 535 |
+
Send request and here is my user with ID seven.
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:10:27,000 --> 00:10:30,000
|
| 539 |
+
Everything works as expected.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:10:30,000 --> 00:10:36,000
|
| 543 |
+
I will not stop too much on this request because it is pretty straightforward.
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:10:36,000 --> 00:10:43,000
|
| 547 |
+
Even in case you have any questions, remember that you can ask your questions below the video and I
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:10:43,000 --> 00:10:45,000
|
| 551 |
+
will be happy to answer those.
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:10:45,000 --> 00:10:46,000
|
| 555 |
+
Let's continue.
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:10:47,000 --> 00:10:50,000
|
| 559 |
+
The next request is with request parameter.
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:10:50,000 --> 00:10:58,000
|
| 563 |
+
This time we want to filter users by the first name and we learned that it is a good practice to use
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:10:58,000 --> 00:11:01,000
|
| 567 |
+
request parameters for filtering and sorting.
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:11:01,000 --> 00:11:10,000
|
| 571 |
+
In this case, I specify first name request parameter that is equal to admin, and in the response I
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:11:10,000 --> 00:11:14,000
|
| 575 |
+
have multiple users who have first name admin.
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:11:15,000 --> 00:11:24,000
|
| 579 |
+
Feel free to use query params section in order to add, enable or disable some query parameters and
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:11:24,000 --> 00:11:26,000
|
| 583 |
+
it will help you to build the query.
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:11:27,000 --> 00:11:35,000
|
| 587 |
+
The main thing is to specify key and value, but optionally for the documenting purposes you can specify
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:11:35,000 --> 00:11:41,000
|
| 591 |
+
description to the next request is similar to the one that we have removed.
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:11:41,000 --> 00:11:46,000
|
| 595 |
+
We use sort by query parameter to sort results by first name field.
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:11:47,000 --> 00:11:53,000
|
| 599 |
+
You can notice that users in our response will be sorted by first name values.
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:11:53,000 --> 00:11:57,000
|
| 603 |
+
The next thing is to demo post request.
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:11:57,000 --> 00:12:01,000
|
| 607 |
+
We created request parameters demo endpoint.
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:12:01,000 --> 00:12:04,000
|
| 611 |
+
Let me show it to you in the source code.
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:12:04,000 --> 00:12:11,000
|
| 615 |
+
Just to remind you, this is the endpoint that can be accessed via post method and request.
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:12:11,000 --> 00:12:18,000
|
| 619 |
+
Params still means not something what is sent in body of the request, but something what is specified
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:12:18,000 --> 00:12:20,000
|
| 623 |
+
in the query as a parameter.
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:12:21,000 --> 00:12:29,000
|
| 627 |
+
So in this case, when I send a request and pass one parameter, it is taken into account on the server
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:12:29,000 --> 00:12:35,000
|
| 631 |
+
side and according to the logic that we created will return it back in the response.
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:12:35,000 --> 00:12:36,000
|
| 635 |
+
Is it clear?
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:12:37,000 --> 00:12:38,000
|
| 639 |
+
Amazing.
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:12:38,000 --> 00:12:44,000
|
| 643 |
+
We also created an endpoint that passes all requests parameters into the map.
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:12:45,000 --> 00:12:54,000
|
| 647 |
+
You can pass multiple parameters and in Java source code you can work with all of them as with the map.
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:12:55,000 --> 00:12:57,000
|
| 651 |
+
And here is how this endpoint works.
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:12:58,000 --> 00:13:03,000
|
| 655 |
+
I send request and return entry set of parameters.
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:13:04,000 --> 00:13:12,000
|
| 659 |
+
In case you want to pass information in the request body similar to the way how we transmit this data
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:13:12,000 --> 00:13:16,000
|
| 663 |
+
with the help of HTML forms, you can do it too.
|
| 664 |
+
|
| 665 |
+
167
|
| 666 |
+
00:13:16,000 --> 00:13:24,000
|
| 667 |
+
Let's navigate to the body tab, specify the data type that you want to send as form data.
|
| 668 |
+
|
| 669 |
+
168
|
| 670 |
+
00:13:25,000 --> 00:13:29,000
|
| 671 |
+
Select is a form data or form URL encoded.
|
| 672 |
+
|
| 673 |
+
169
|
| 674 |
+
00:13:29,000 --> 00:13:32,000
|
| 675 |
+
What is the difference between these?
|
| 676 |
+
|
| 677 |
+
170
|
| 678 |
+
00:13:32,000 --> 00:13:40,000
|
| 679 |
+
The main difference between the two is in how the data is formatted and send form.
|
| 680 |
+
|
| 681 |
+
171
|
| 682 |
+
00:13:40,000 --> 00:13:47,000
|
| 683 |
+
Data is used to send binary data such as images or files as well as text data.
|
| 684 |
+
|
| 685 |
+
172
|
| 686 |
+
00:13:47,000 --> 00:13:55,000
|
| 687 |
+
It is commonly used when uploading files or submitting forms with file inputs in form data.
|
| 688 |
+
|
| 689 |
+
173
|
| 690 |
+
00:13:55,000 --> 00:14:03,000
|
| 691 |
+
Each key value pair is separated by a boundary string and is sent in a separate section, which makes
|
| 692 |
+
|
| 693 |
+
174
|
| 694 |
+
00:14:03,000 --> 00:14:07,000
|
| 695 |
+
it more suitable for sending large files.
|
| 696 |
+
|
| 697 |
+
175
|
| 698 |
+
00:14:08,000 --> 00:14:11,000
|
| 699 |
+
X3W form urlencoded.
|
| 700 |
+
|
| 701 |
+
176
|
| 702 |
+
00:14:11,000 --> 00:14:20,000
|
| 703 |
+
On the other hand, is used to send simple text data in the format of key value pairs separated by an
|
| 704 |
+
|
| 705 |
+
177
|
| 706 |
+
00:14:20,000 --> 00:14:22,000
|
| 707 |
+
ampersand symbol.
|
| 708 |
+
|
| 709 |
+
178
|
| 710 |
+
00:14:22,000 --> 00:14:29,000
|
| 711 |
+
It is commonly used when submitting form data without file inputs in form.
|
| 712 |
+
|
| 713 |
+
179
|
| 714 |
+
00:14:29,000 --> 00:14:30,000
|
| 715 |
+
Urlencoded.
|
| 716 |
+
|
| 717 |
+
180
|
| 718 |
+
00:14:30,000 --> 00:14:35,000
|
| 719 |
+
The data is encoded and sent as a single string in the request body.
|
| 720 |
+
|
| 721 |
+
181
|
| 722 |
+
00:14:36,000 --> 00:14:42,000
|
| 723 |
+
In summary, if you need to send binary data or large files, use form data.
|
| 724 |
+
|
| 725 |
+
182
|
| 726 |
+
00:14:42,000 --> 00:14:49,000
|
| 727 |
+
If you are sending simple text data, use X3W form URL encoded.
|
| 728 |
+
|
| 729 |
+
183
|
| 730 |
+
00:14:49,000 --> 00:14:55,000
|
| 731 |
+
So in this case I select form URL encoded and send the request.
|
| 732 |
+
|
| 733 |
+
184
|
| 734 |
+
00:14:56,000 --> 00:15:00,000
|
| 735 |
+
In response we can see form data from the request body.
|
| 736 |
+
|
| 737 |
+
185
|
| 738 |
+
00:15:00,000 --> 00:15:08,000
|
| 739 |
+
And just to remind you that on the backend side we need to specify that this endpoint consumes specific
|
| 740 |
+
|
| 741 |
+
186
|
| 742 |
+
00:15:08,000 --> 00:15:11,000
|
| 743 |
+
media type in the source code.
|
| 744 |
+
|
| 745 |
+
187
|
| 746 |
+
00:15:11,000 --> 00:15:17,000
|
| 747 |
+
You can see that I specified that this endpoint consumes application form URL encoded.
|
| 748 |
+
|
| 749 |
+
188
|
| 750 |
+
00:15:17,000 --> 00:15:19,000
|
| 751 |
+
That's how it works.
|
| 752 |
+
|
| 753 |
+
189
|
| 754 |
+
00:15:19,000 --> 00:15:26,000
|
| 755 |
+
Also, I wanted to show you that theoretically you can pass list of parameters, comma, separated values
|
| 756 |
+
|
| 757 |
+
190
|
| 758 |
+
00:15:26,000 --> 00:15:29,000
|
| 759 |
+
like you can see in this example.
|
| 760 |
+
|
| 761 |
+
191
|
| 762 |
+
00:15:29,000 --> 00:15:37,000
|
| 763 |
+
You can send multiple IDs at once, putting them in one request parameter that is called IDs.
|
| 764 |
+
|
| 765 |
+
192
|
| 766 |
+
00:15:38,000 --> 00:15:42,000
|
| 767 |
+
On the backend side, they are passed into the list of values.
|
| 768 |
+
|
| 769 |
+
193
|
| 770 |
+
00:15:43,000 --> 00:15:46,000
|
| 771 |
+
I just print the list of values into the response.
|
| 772 |
+
|
| 773 |
+
194
|
| 774 |
+
00:15:46,000 --> 00:15:52,000
|
| 775 |
+
Nothing special, but you can build your business logic around the list of values.
|
| 776 |
+
|
| 777 |
+
195
|
| 778 |
+
00:15:52,000 --> 00:15:53,000
|
| 779 |
+
As you wish.
|
| 780 |
+
|
| 781 |
+
196
|
| 782 |
+
00:15:54,000 --> 00:16:01,000
|
| 783 |
+
The next thing that I would like to show you is how you can test that custom response status is returned.
|
| 784 |
+
|
| 785 |
+
197
|
| 786 |
+
00:16:02,000 --> 00:16:08,000
|
| 787 |
+
Just to remind you that on the backend for one of our endpoints, we configure it.
|
| 788 |
+
|
| 789 |
+
198
|
| 790 |
+
00:16:08,000 --> 00:16:16,000
|
| 791 |
+
I'm a T port response status and when I send requests to this endpoint in the Postman, I can see that
|
| 792 |
+
|
| 793 |
+
199
|
| 794 |
+
00:16:16,000 --> 00:16:20,000
|
| 795 |
+
the response status code is 418.
|
| 796 |
+
|
| 797 |
+
200
|
| 798 |
+
00:16:20,000 --> 00:16:22,000
|
| 799 |
+
You can see status code here.
|
| 800 |
+
|
| 801 |
+
201
|
| 802 |
+
00:16:23,000 --> 00:16:28,000
|
| 803 |
+
This is achieved by using response status annotation in the source code.
|
| 804 |
+
|
| 805 |
+
202
|
| 806 |
+
00:16:28,000 --> 00:16:36,000
|
| 807 |
+
Another interesting thing about Postman, you can see that server generated HTML page for us.
|
| 808 |
+
|
| 809 |
+
203
|
| 810 |
+
00:16:36,000 --> 00:16:41,000
|
| 811 |
+
You can use preview mode in order to preview page markup.
|
| 812 |
+
|
| 813 |
+
204
|
| 814 |
+
00:16:41,000 --> 00:16:49,000
|
| 815 |
+
Also here you can see the reason that we also specified in the response status annotation demo endpoint
|
| 816 |
+
|
| 817 |
+
205
|
| 818 |
+
00:16:49,000 --> 00:16:50,000
|
| 819 |
+
reason.
|
| 820 |
+
|
| 821 |
+
206
|
| 822 |
+
00:16:50,000 --> 00:16:54,000
|
| 823 |
+
Now let's delete the resource using rest API.
|
| 824 |
+
|
| 825 |
+
207
|
| 826 |
+
00:16:55,000 --> 00:17:00,000
|
| 827 |
+
If you remember, we have test user John Doe with a 12.
|
| 828 |
+
|
| 829 |
+
208
|
| 830 |
+
00:17:00,000 --> 00:17:02,000
|
| 831 |
+
Let's remove it.
|
| 832 |
+
|
| 833 |
+
209
|
| 834 |
+
00:17:02,000 --> 00:17:08,000
|
| 835 |
+
I specify user ID that I want to delete and send request via delete method.
|
| 836 |
+
|
| 837 |
+
210
|
| 838 |
+
00:17:09,000 --> 00:17:13,000
|
| 839 |
+
Pay attention that no content string has been returned.
|
| 840 |
+
|
| 841 |
+
211
|
| 842 |
+
00:17:13,000 --> 00:17:14,000
|
| 843 |
+
Why?
|
| 844 |
+
|
| 845 |
+
212
|
| 846 |
+
00:17:14,000 --> 00:17:21,000
|
| 847 |
+
Because I used HTTP status as a returned value and it was casted to string value.
|
| 848 |
+
|
| 849 |
+
213
|
| 850 |
+
00:17:22,000 --> 00:17:25,000
|
| 851 |
+
The actual status of the response is 200.
|
| 852 |
+
|
| 853 |
+
214
|
| 854 |
+
00:17:25,000 --> 00:17:26,000
|
| 855 |
+
Okay.
|
| 856 |
+
|
| 857 |
+
215
|
| 858 |
+
00:17:27,000 --> 00:17:27,000
|
| 859 |
+
Why?
|
| 860 |
+
|
| 861 |
+
216
|
| 862 |
+
00:17:27,000 --> 00:17:28,000
|
| 863 |
+
I show you this.
|
| 864 |
+
|
| 865 |
+
217
|
| 866 |
+
00:17:29,000 --> 00:17:36,000
|
| 867 |
+
Just to highlight that in case you want to control response status, setting up the returned value is
|
| 868 |
+
|
| 869 |
+
218
|
| 870 |
+
00:17:36,000 --> 00:17:37,000
|
| 871 |
+
not enough.
|
| 872 |
+
|
| 873 |
+
219
|
| 874 |
+
00:17:37,000 --> 00:17:42,000
|
| 875 |
+
You need to use response status annotation to configure custom response status.
|
| 876 |
+
|
| 877 |
+
220
|
| 878 |
+
00:17:43,000 --> 00:17:50,000
|
| 879 |
+
And this time, in case we would request user's resource, we are going to see that there is no John
|
| 880 |
+
|
| 881 |
+
221
|
| 882 |
+
00:17:50,000 --> 00:17:52,000
|
| 883 |
+
Doe user object anymore.
|
| 884 |
+
|
| 885 |
+
222
|
| 886 |
+
00:17:53,000 --> 00:17:57,000
|
| 887 |
+
Thus, we can be sure that endpoint works as expected.
|
| 888 |
+
|
| 889 |
+
223
|
| 890 |
+
00:17:58,000 --> 00:18:00,000
|
| 891 |
+
Let's now create the resource.
|
| 892 |
+
|
| 893 |
+
224
|
| 894 |
+
00:18:00,000 --> 00:18:03,000
|
| 895 |
+
Usually we create resources with the post method.
|
| 896 |
+
|
| 897 |
+
225
|
| 898 |
+
00:18:04,000 --> 00:18:07,000
|
| 899 |
+
In our rest service we have users endpoint.
|
| 900 |
+
|
| 901 |
+
226
|
| 902 |
+
00:18:08,000 --> 00:18:12,000
|
| 903 |
+
Does it create resource in case resource is reached with a post method?
|
| 904 |
+
|
| 905 |
+
227
|
| 906 |
+
00:18:13,000 --> 00:18:23,000
|
| 907 |
+
In this case we need to open body tab, select row form of data and insert the JSON of your user resource.
|
| 908 |
+
|
| 909 |
+
228
|
| 910 |
+
00:18:24,000 --> 00:18:33,000
|
| 911 |
+
You can see here that I pass key value pairs That reflects the state of the user object and I just click
|
| 912 |
+
|
| 913 |
+
229
|
| 914 |
+
00:18:33,000 --> 00:18:34,000
|
| 915 |
+
send request button.
|
| 916 |
+
|
| 917 |
+
230
|
| 918 |
+
00:18:35,000 --> 00:18:36,000
|
| 919 |
+
That's it.
|
| 920 |
+
|
| 921 |
+
231
|
| 922 |
+
00:18:36,000 --> 00:18:38,000
|
| 923 |
+
Resource is created.
|
| 924 |
+
|
| 925 |
+
232
|
| 926 |
+
00:18:38,000 --> 00:18:43,000
|
| 927 |
+
Let's now call all users to make sure that the new user is created.
|
| 928 |
+
|
| 929 |
+
233
|
| 930 |
+
00:18:44,000 --> 00:18:49,000
|
| 931 |
+
And in the bottom we can see that new user with fake data was created.
|
| 932 |
+
|
| 933 |
+
234
|
| 934 |
+
00:18:50,000 --> 00:18:51,000
|
| 935 |
+
Amazing.
|
| 936 |
+
|
| 937 |
+
235
|
| 938 |
+
00:18:51,000 --> 00:18:55,000
|
| 939 |
+
Let's imagine now that we want to update resource.
|
| 940 |
+
|
| 941 |
+
236
|
| 942 |
+
00:18:55,000 --> 00:18:58,000
|
| 943 |
+
Usually we update resource, we have put method.
|
| 944 |
+
|
| 945 |
+
237
|
| 946 |
+
00:18:59,000 --> 00:19:08,000
|
| 947 |
+
So in the next example, I also send JSON in the body of the request, but I want to update an email.
|
| 948 |
+
|
| 949 |
+
238
|
| 950 |
+
00:19:09,000 --> 00:19:13,000
|
| 951 |
+
I want to change email in order it would have test email domain.
|
| 952 |
+
|
| 953 |
+
239
|
| 954 |
+
00:19:14,000 --> 00:19:16,000
|
| 955 |
+
Let me send the request.
|
| 956 |
+
|
| 957 |
+
240
|
| 958 |
+
00:19:16,000 --> 00:19:19,000
|
| 959 |
+
Web server accepted my request.
|
| 960 |
+
|
| 961 |
+
241
|
| 962 |
+
00:19:19,000 --> 00:19:21,000
|
| 963 |
+
Let's check all users again.
|
| 964 |
+
|
| 965 |
+
242
|
| 966 |
+
00:19:23,000 --> 00:19:32,000
|
| 967 |
+
And you can see that email value right now ends up not with Email.com but with test email.com.
|
| 968 |
+
|
| 969 |
+
243
|
| 970 |
+
00:19:32,000 --> 00:19:40,000
|
| 971 |
+
And pay attention that in real life, in case you have applications that consists from multiple services,
|
| 972 |
+
|
| 973 |
+
244
|
| 974 |
+
00:19:40,000 --> 00:19:45,000
|
| 975 |
+
the services can exchange the data and communicate in the similar way.
|
| 976 |
+
|
| 977 |
+
245
|
| 978 |
+
00:19:45,000 --> 00:19:53,000
|
| 979 |
+
We just use Postman as a client now, but in real life this can be any other application generating
|
| 980 |
+
|
| 981 |
+
246
|
| 982 |
+
00:19:53,000 --> 00:19:57,000
|
| 983 |
+
requests and acting as a client of our application.
|
| 984 |
+
|
| 985 |
+
247
|
| 986 |
+
00:19:57,000 --> 00:20:04,000
|
| 987 |
+
The next thing that I wanted you to demo is how to return an object of response entity type.
|
| 988 |
+
|
| 989 |
+
248
|
| 990 |
+
00:20:04,000 --> 00:20:11,000
|
| 991 |
+
You can remember that in previous lesson when we created our restful service, I showed you that you
|
| 992 |
+
|
| 993 |
+
249
|
| 994 |
+
00:20:11,000 --> 00:20:19,000
|
| 995 |
+
can return response entity in order to configure response status response headers and response body
|
| 996 |
+
|
| 997 |
+
250
|
| 998 |
+
00:20:19,000 --> 00:20:20,000
|
| 999 |
+
in one object.
|
| 1000 |
+
|
| 1001 |
+
251
|
| 1002 |
+
00:20:21,000 --> 00:20:29,000
|
| 1003 |
+
In this particular example, you can see that after I send request, I receive custom response body
|
| 1004 |
+
|
| 1005 |
+
252
|
| 1006 |
+
00:20:29,000 --> 00:20:31,000
|
| 1007 |
+
and custom response header.
|
| 1008 |
+
|
| 1009 |
+
253
|
| 1010 |
+
00:20:31,000 --> 00:20:34,000
|
| 1011 |
+
Let me show it to you on the header.
|
| 1012 |
+
|
| 1013 |
+
254
|
| 1014 |
+
00:20:34,000 --> 00:20:34,000
|
| 1015 |
+
Stop.
|
| 1016 |
+
|
| 1017 |
+
255
|
| 1018 |
+
00:20:35,000 --> 00:20:39,000
|
| 1019 |
+
Here you can see custom header and fake data.
|
| 1020 |
+
|
| 1021 |
+
256
|
| 1022 |
+
00:20:40,000 --> 00:20:45,000
|
| 1023 |
+
Also, if you wish, you can configure custom status code.
|
| 1024 |
+
|
| 1025 |
+
257
|
| 1026 |
+
00:20:46,000 --> 00:20:51,000
|
| 1027 |
+
The next example is to demo and check request header annotation.
|
| 1028 |
+
|
| 1029 |
+
258
|
| 1030 |
+
00:20:52,000 --> 00:20:59,000
|
| 1031 |
+
I can specify custom headers and submit them to the rest API on the header stop.
|
| 1032 |
+
|
| 1033 |
+
259
|
| 1034 |
+
00:20:59,000 --> 00:21:05,000
|
| 1035 |
+
You can see headers that are added by default here and additional custom header.
|
| 1036 |
+
|
| 1037 |
+
260
|
| 1038 |
+
00:21:05,000 --> 00:21:14,000
|
| 1039 |
+
For example, in case I want to send accept language header, I just add it here and specify value for
|
| 1040 |
+
|
| 1041 |
+
261
|
| 1042 |
+
00:21:14,000 --> 00:21:14,000
|
| 1043 |
+
it.
|
| 1044 |
+
|
| 1045 |
+
262
|
| 1046 |
+
00:21:14,000 --> 00:21:22,000
|
| 1047 |
+
And as usual, you're welcome to leave any description in case it would help us in documenting the requests.
|
| 1048 |
+
|
| 1049 |
+
263
|
| 1050 |
+
00:21:23,000 --> 00:21:31,000
|
| 1051 |
+
When I send a request, my endpoint passes, request header and return header value in response.
|
| 1052 |
+
|
| 1053 |
+
264
|
| 1054 |
+
00:21:32,000 --> 00:21:34,000
|
| 1055 |
+
Everything works as expected.
|
| 1056 |
+
|
| 1057 |
+
265
|
| 1058 |
+
00:21:34,000 --> 00:21:36,000
|
| 1059 |
+
Let's move on.
|
| 1060 |
+
|
| 1061 |
+
266
|
| 1062 |
+
00:21:36,000 --> 00:21:43,000
|
| 1063 |
+
In the next example, I demonstrate endpoints that parses all the headers into the map and in the source
|
| 1064 |
+
|
| 1065 |
+
267
|
| 1066 |
+
00:21:43,000 --> 00:21:49,000
|
| 1067 |
+
code you can work with the map of key value pairs that represent headers.
|
| 1068 |
+
|
| 1069 |
+
268
|
| 1070 |
+
00:21:49,000 --> 00:21:54,000
|
| 1071 |
+
In this particular case, I just send them back in the response.
|
| 1072 |
+
|
| 1073 |
+
269
|
| 1074 |
+
00:21:54,000 --> 00:21:55,000
|
| 1075 |
+
That's it.
|
| 1076 |
+
|
| 1077 |
+
270
|
| 1078 |
+
00:21:55,000 --> 00:21:58,000
|
| 1079 |
+
We tested all our endpoints.
|
| 1080 |
+
|
| 1081 |
+
271
|
| 1082 |
+
00:21:59,000 --> 00:22:04,000
|
| 1083 |
+
I hope that this lesson was useful for you and it will help you during the daily activities.
|
| 1084 |
+
|
| 1085 |
+
272
|
| 1086 |
+
00:22:04,000 --> 00:22:08,000
|
| 1087 |
+
Let's recap what we have learned in the lesson.
|
| 1088 |
+
|
| 1089 |
+
273
|
| 1090 |
+
00:22:09,000 --> 00:22:14,000
|
| 1091 |
+
Today we learned postman user interface and key UI elements.
|
| 1092 |
+
|
| 1093 |
+
274
|
| 1094 |
+
00:22:14,000 --> 00:22:22,000
|
| 1095 |
+
I showed you how we can work with collections, how to import export collections, and how to create
|
| 1096 |
+
|
| 1097 |
+
275
|
| 1098 |
+
00:22:22,000 --> 00:22:23,000
|
| 1099 |
+
new collections of requests.
|
| 1100 |
+
|
| 1101 |
+
276
|
| 1102 |
+
00:22:24,000 --> 00:22:28,000
|
| 1103 |
+
You saw how to work with requests and responses.
|
| 1104 |
+
|
| 1105 |
+
277
|
| 1106 |
+
00:22:28,000 --> 00:22:33,000
|
| 1107 |
+
During the lesson, we sent requests with a different HTTP methods.
|
| 1108 |
+
|
| 1109 |
+
278
|
| 1110 |
+
00:22:33,000 --> 00:22:37,000
|
| 1111 |
+
Also, you saw how to read responses.
|
| 1112 |
+
|
| 1113 |
+
279
|
| 1114 |
+
00:22:38,000 --> 00:22:43,000
|
| 1115 |
+
We worked with custom headers by sending them and receiving custom headers.
|
| 1116 |
+
|
| 1117 |
+
280
|
| 1118 |
+
00:22:43,000 --> 00:22:48,000
|
| 1119 |
+
We tested our restful service and all its endpoints.
|
| 1120 |
+
|
| 1121 |
+
281
|
| 1122 |
+
00:22:49,000 --> 00:22:56,000
|
| 1123 |
+
Also, you learned how to execute, create, read, update and delete operations with resource.
|
| 1124 |
+
|
| 1125 |
+
282
|
| 1126 |
+
00:22:56,000 --> 00:23:04,000
|
| 1127 |
+
And at the end of the lesson, we learned the difference between form data and X3W form URL encoded.
|
| 1128 |
+
|
| 1129 |
+
283
|
| 1130 |
+
00:23:05,000 --> 00:23:07,000
|
| 1131 |
+
That's all for this lesson.
|
| 1132 |
+
|
| 1133 |
+
284
|
| 1134 |
+
00:23:07,000 --> 00:23:09,000
|
| 1135 |
+
Thanks a lot for your attention.
|
| 1136 |
+
|
| 1137 |
+
285
|
| 1138 |
+
00:23:09,000 --> 00:23:12,000
|
| 1139 |
+
Have a great day and see you in the next lesson.
|
| 1140 |
+
|
91 - REST Architecture/005 Commit-with-changes.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/36722187fd1478db83cd95bd24f6204e4e228092
|
91 - REST Architecture/005 Postman-collections.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/AndriiPiatakha/java-learnit-spring-web/tree/master/src/main/resources/postman-collections
|
91 - REST Architecture/external-links.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
003 Source-code-of-examples-commit-with-changes-
|
| 3 |
+
https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/5f6b4f695bb88865978fb7cbe622855783c17cfa
|
| 4 |
+
|
| 5 |
+
005 Postman-collections
|
| 6 |
+
https://github.com/AndriiPiatakha/java-learnit-spring-web/tree/master/src/main/resources/postman-collections
|
| 7 |
+
|
| 8 |
+
005 Commit-with-changes
|
| 9 |
+
https://github.com/AndriiPiatakha/java-learnit-spring-web/commit/36722187fd1478db83cd95bd24f6204e4e228092
|
92 - Spring Boot/001 Spring Boot Introduction_en.srt
ADDED
|
@@ -0,0 +1,1084 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:05,000 --> 00:00:06,000
|
| 3 |
+
Hello, Kim.
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:06,000 --> 00:00:13,000
|
| 7 |
+
With this lesson, we start learning Spring Boot taking into account this is an introduction to Spring
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:13,000 --> 00:00:13,000
|
| 11 |
+
boot.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:13,000 --> 00:00:20,000
|
| 15 |
+
This is going to be theoretical lesson, but I'm sure that it is super important in order we can set
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:20,000 --> 00:00:27,000
|
| 19 |
+
the context, understand what spring boot is, when to use it, and other general things.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:27,000 --> 00:00:34,000
|
| 23 |
+
We're going to start from the important question that students ask me very often where to start learning
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:34,000 --> 00:00:35,000
|
| 27 |
+
of Spring boot.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:35,000 --> 00:00:39,000
|
| 31 |
+
Do we need to start learning other modules from spring framework?
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:39,000 --> 00:00:42,000
|
| 35 |
+
Or we can start learning of the spring boot directly?
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:42,000 --> 00:00:47,000
|
| 39 |
+
We are going to review this question and we will try to answer it.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:47,000 --> 00:00:53,000
|
| 43 |
+
You're going to understand what is the difference and what a connection between Spring framework and
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:53,000 --> 00:00:54,000
|
| 47 |
+
Spring boot.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:54,000 --> 00:00:57,000
|
| 51 |
+
I will explain you what Spring Boot is.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:57,000 --> 00:01:05,000
|
| 55 |
+
We'll discuss its key features, take into account that opinionated development approach is used in
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:01:05,000 --> 00:01:06,000
|
| 59 |
+
the spring boot.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:01:06,000 --> 00:01:08,000
|
| 63 |
+
We're going to learn what it is.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:01:09,000 --> 00:01:14,000
|
| 67 |
+
I will explain when to use and when not to use Spring Boot.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:01:14,000 --> 00:01:20,000
|
| 71 |
+
And at the end of the lesson, we are going to summarize advantages and disadvantages of Spring Boot.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:01:20,000 --> 00:01:22,000
|
| 75 |
+
Let's start our lesson.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:01:22,000 --> 00:01:26,000
|
| 79 |
+
Let's start from the first and important question.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:01:26,000 --> 00:01:33,000
|
| 83 |
+
A lot of students of mine ask me where to start learning Spring Boot and what's it worth to start learning
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:01:33,000 --> 00:01:40,000
|
| 87 |
+
Spring Boot straight away in case there is no understanding about Spring Framework and its other projects.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:01:40,000 --> 00:01:47,000
|
| 91 |
+
Because very often students hear Spring boot like a buzzword and believes that they need to learn it
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:01:47,000 --> 00:01:54,000
|
| 95 |
+
as soon as possible and start learning it without understanding of what spring framework is.
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:01:54,000 --> 00:02:02,000
|
| 99 |
+
In general, if a student of my course Java from zero to first job, then you remember that when we
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:02:02,000 --> 00:02:08,000
|
| 103 |
+
started learning of spring modules, different spring projects, I said that there are two different
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:02:08,000 --> 00:02:10,000
|
| 107 |
+
approaches in learning Spring framework.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:02:10,000 --> 00:02:18,000
|
| 111 |
+
The first one is to run projects from spring framework and only then start learning Spring Boot and
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:02:18,000 --> 00:02:25,000
|
| 115 |
+
the second approach start learning of spring boot and gradually learn all the projects of Spring framework.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:02:25,000 --> 00:02:33,000
|
| 119 |
+
Based on my experience and work with many students during multiple years, I can confirm that In my
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:02:33,000 --> 00:02:38,000
|
| 123 |
+
opinion, you should start from learning Spring framework and its different projects.
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:02:38,000 --> 00:02:39,000
|
| 127 |
+
Why?
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:02:39,000 --> 00:02:44,000
|
| 131 |
+
Because at the end of the day, Spring Boot is built on top of spring framework.
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:02:44,000 --> 00:02:51,000
|
| 135 |
+
So understanding spring frameworks, core concepts and features is essential.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:02:51,000 --> 00:02:58,000
|
| 139 |
+
Before diving into spring boot, Spring Framework provides a strong foundation for building enterprise
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:02:58,000 --> 00:03:05,000
|
| 143 |
+
level Java applications, and it includes several modules that cover different aspects of application
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:03:05,000 --> 00:03:11,000
|
| 147 |
+
development, such as core container data, access, web and more.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:03:11,000 --> 00:03:19,000
|
| 151 |
+
Familiarity with these modules will give you a better understanding of how Spring Boot works and its
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:03:19,000 --> 00:03:21,000
|
| 155 |
+
underlying mechanisms.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:03:21,000 --> 00:03:27,000
|
| 159 |
+
Once you have a good understanding of spring framework, you can then move on to spring boot.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:03:27,000 --> 00:03:34,000
|
| 163 |
+
Spring Boot simplifies the setup and configuration of spring based applications, making it easier to
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:03:34,000 --> 00:03:40,000
|
| 167 |
+
create standalone production grade spring applications quickly.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:03:40,000 --> 00:03:47,000
|
| 171 |
+
However, it is important to note that Spring Boot doesn't replace spring framework entirely, as it
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:03:47,000 --> 00:03:50,000
|
| 175 |
+
still relies on many of its core components.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:03:50,000 --> 00:03:58,000
|
| 179 |
+
So it is best for students to learn spring framework first and then move on to Spring Boot to gain a
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:03:58,000 --> 00:04:05,000
|
| 183 |
+
deeper understanding of how both frameworks work together to create powerful and scalable applications.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:04:05,000 --> 00:04:12,000
|
| 187 |
+
By saying this, I want to highlight that in case you didn't watch previous lessons about spring, I
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:04:12,000 --> 00:04:18,000
|
| 191 |
+
would recommend you to start from them because it will help you to understand some basic concepts about
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:04:18,000 --> 00:04:21,000
|
| 195 |
+
spring framework and some terminology.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:04:21,000 --> 00:04:24,000
|
| 199 |
+
In this lesson we start learning spring Boot.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:04:24,000 --> 00:04:27,000
|
| 203 |
+
So let's understand what a spring boot is.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:04:28,000 --> 00:04:35,000
|
| 207 |
+
Spring Boot is a popular Java based framework that is used to create standalone production, ready spring
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:04:35,000 --> 00:04:40,000
|
| 211 |
+
applications quickly and with minimal setup like we already discussed.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:04:40,000 --> 00:04:47,000
|
| 215 |
+
It is built on top of the spring framework and provides a number of additional features and improvements
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:04:47,000 --> 00:04:55,000
|
| 219 |
+
to simplify the development process and reduce the time and effort required to build complex applications.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:04:55,000 --> 00:05:01,000
|
| 223 |
+
Also, we can say that Spring Boot is a spring module that provides the rapid application development
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:05:01,000 --> 00:05:03,000
|
| 227 |
+
feature to the spring framework.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:05:03,000 --> 00:05:11,000
|
| 231 |
+
It is used to create a standalone spring based application that you can just run because it needs minimal
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:05:11,000 --> 00:05:12,000
|
| 235 |
+
spring configuration.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:05:13,000 --> 00:05:21,000
|
| 239 |
+
In short, Spring Boot is a combination of spring framework and embedded server, so you even don't
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:05:21,000 --> 00:05:24,000
|
| 243 |
+
need to configure Tomcat separately.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:05:24,000 --> 00:05:32,000
|
| 247 |
+
The web server is built in and you can run the application with Java very simply because the application
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:05:32,000 --> 00:05:35,000
|
| 251 |
+
is packaged into the jar archive.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:05:36,000 --> 00:05:36,000
|
| 255 |
+
In spring boot.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:05:37,000 --> 00:05:42,000
|
| 259 |
+
There is no requirement for XML configuration deployment descriptor.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:05:42,000 --> 00:05:47,000
|
| 263 |
+
It uses convention over configuration software design paradigm.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:05:47,000 --> 00:05:50,000
|
| 267 |
+
That means it decreases the effort of the developer.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:05:51,000 --> 00:05:58,000
|
| 271 |
+
One of the key features of Spring Boot is its opinionated approach to application development, which
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:05:58,000 --> 00:06:06,000
|
| 275 |
+
means that it provides a set of defaults and conventions that are optimized for common use cases.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:06:06,000 --> 00:06:13,000
|
| 279 |
+
This approach minimizes the need for developers to make many decisions about configuration and setup,
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:06:13,000 --> 00:06:17,000
|
| 283 |
+
allowing them to focus on writing business logic instead.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:06:18,000 --> 00:06:23,000
|
| 287 |
+
We're going to talk more about the opinionated approach on the separate slide.
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:06:23,000 --> 00:06:31,000
|
| 291 |
+
Spring Boot also includes a number of built in features and tools that are designed to make common tasks,
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:06:31,000 --> 00:06:39,000
|
| 295 |
+
such as setting up a web server, handling data persistence, or integrating with external services
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:06:39,000 --> 00:06:42,000
|
| 299 |
+
as simple and straightforward as possible.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:06:42,000 --> 00:06:49,000
|
| 303 |
+
Additionally, Spring Boot has a large and active community, which means that developers can easily
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:06:49,000 --> 00:06:56,000
|
| 307 |
+
find help, resources and third party plugins to extend its functionality.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:06:57,000 --> 00:07:04,000
|
| 311 |
+
Overall, Spring Boot is an excellent choice for Java developers who want to create robust, scalable
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:07:04,000 --> 00:07:08,000
|
| 315 |
+
and maintainable applications quickly and efficiently.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:07:09,000 --> 00:07:11,000
|
| 319 |
+
Let's now learn features of Spring boot.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:07:12,000 --> 00:07:14,000
|
| 323 |
+
This will help you to understand it better.
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:07:15,000 --> 00:07:22,000
|
| 327 |
+
Spring Boot comes with a rich set of features that make it an excellent choice for developing modern
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:07:22,000 --> 00:07:24,000
|
| 331 |
+
Java applications.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:07:24,000 --> 00:07:26,000
|
| 335 |
+
Here are some of its key features.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:07:27,000 --> 00:07:29,000
|
| 339 |
+
Easy setup and configuration.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:07:29,000 --> 00:07:30,000
|
| 343 |
+
Spring Boot.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:07:30,000 --> 00:07:38,000
|
| 347 |
+
Opinionated approach to application development simplifies the setup process and provides a set of default
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:07:38,000 --> 00:07:42,000
|
| 351 |
+
configurations that are optimized for common use cases.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:07:43,000 --> 00:07:50,000
|
| 355 |
+
Developers can get up and running with a new project quickly without having to spend a lot of time on
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:07:50,000 --> 00:07:51,000
|
| 359 |
+
configuration and setup.
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:07:52,000 --> 00:07:54,000
|
| 363 |
+
Built in web server.
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:07:54,000 --> 00:08:00,000
|
| 367 |
+
I already told you that Spring Boot includes an embedded web server which allows developers to easily
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:08:00,000 --> 00:08:07,000
|
| 371 |
+
create web based applications without having to configure and manage an external web server.
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:08:07,000 --> 00:08:15,000
|
| 375 |
+
So there is no problems with questions which Tomcat version to download and how to run it and how to
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:08:15,000 --> 00:08:17,000
|
| 379 |
+
deploy our web application.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:08:18,000 --> 00:08:19,000
|
| 383 |
+
Dependency management.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:08:19,000 --> 00:08:26,000
|
| 387 |
+
Spring Boot includes a powerful dependency management system that makes it easy to manage the dependencies
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:08:26,000 --> 00:08:29,000
|
| 391 |
+
required by an application.
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:08:29,000 --> 00:08:36,000
|
| 395 |
+
It automatically manages versions and conflicts and can then load and cache dependencies automatically.
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:08:36,000 --> 00:08:40,000
|
| 399 |
+
But be aware that each feature comes with a price.
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:08:40,000 --> 00:08:47,000
|
| 403 |
+
A little bit later in the lesson, I am going to explain that automatic dependency management can lead
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:08:47,000 --> 00:08:48,000
|
| 407 |
+
to troubles.
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:08:48,000 --> 00:08:53,000
|
| 411 |
+
Basically, everything what is happened without our control can lead to troubles.
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:08:53,000 --> 00:08:55,000
|
| 415 |
+
Just remember this.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:08:56,000 --> 00:08:57,000
|
| 419 |
+
Automatic configuration.
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:08:58,000 --> 00:09:04,000
|
| 423 |
+
Spring Boot uses convention over configuration to automatically configure common components such as
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:09:04,000 --> 00:09:11,000
|
| 427 |
+
data sources, messaging systems, and web servers based on the dependencies that are included in an
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:09:11,000 --> 00:09:12,000
|
| 431 |
+
application.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:09:13,000 --> 00:09:14,000
|
| 435 |
+
Actuator.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:09:14,000 --> 00:09:23,000
|
| 439 |
+
Spring boot actuator provides a set of endpoints and tools that make it easy to monitor and manage an
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:09:23,000 --> 00:09:25,000
|
| 443 |
+
application at runtime.
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:09:25,000 --> 00:09:33,000
|
| 447 |
+
It includes health checks, metrics and other diagnostic tools that can be used to monitor and troubleshoot
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:09:33,000 --> 00:09:35,000
|
| 451 |
+
an application in production.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:09:36,000 --> 00:09:38,000
|
| 455 |
+
Spring Boot Common Line interface.
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:09:38,000 --> 00:09:44,000
|
| 459 |
+
Spring Boot includes a command line interface that makes it easy to quickly prototype and develop new
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:09:44,000 --> 00:09:46,000
|
| 463 |
+
applications.
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:09:46,000 --> 00:09:53,000
|
| 467 |
+
The command line interface provides a set of commands for creating testing and running applications.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:09:54,000 --> 00:09:55,000
|
| 471 |
+
Integrations.
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:09:55,000 --> 00:10:02,000
|
| 475 |
+
Spring Boot integrates with a wide range of other technologies and frameworks, including Spring Cloud
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:10:02,000 --> 00:10:03,000
|
| 479 |
+
and more.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:10:03,000 --> 00:10:10,000
|
| 483 |
+
Overall, Spring Boot is a powerful and flexible framework that makes it easy to develop, deploy and
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:10:10,000 --> 00:10:13,000
|
| 487 |
+
manage modern Java applications.
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:10:13,000 --> 00:10:21,000
|
| 491 |
+
Its rich set of features and tools make it a popular choice for developers of all levels of experience.
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:10:21,000 --> 00:10:26,000
|
| 495 |
+
Previously, I mentioned that Spring Boot uses opinionated development approach.
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:10:26,000 --> 00:10:29,000
|
| 499 |
+
Let's understand what it is.
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:10:29,000 --> 00:10:36,000
|
| 503 |
+
Opinionated development is an approach that emphasizes a strong point of view on how software should
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:10:36,000 --> 00:10:39,000
|
| 507 |
+
be designed, built and deployed.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:10:39,000 --> 00:10:46,000
|
| 511 |
+
In this approach, a framework or toolset provides a set of predefined conventions and best practices
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:10:46,000 --> 00:10:52,000
|
| 515 |
+
that guide developers towards a specific way of building applications.
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:10:53,000 --> 00:10:59,000
|
| 519 |
+
According to another definition, an opinionated approach is a software design pattern that guides users
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:10:59,000 --> 00:11:07,000
|
| 523 |
+
when creating spring apps, that helps developers add and customize starter dependencies.
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:11:07,000 --> 00:11:15,000
|
| 527 |
+
Spring Boots Opinionated approach chooses the right values and packages to install saving developers
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:11:15,000 --> 00:11:15,000
|
| 531 |
+
time.
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:11:16,000 --> 00:11:22,000
|
| 535 |
+
An opinionated framework like Spring Boot is designed to make certain decisions for developers, reducing
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:11:22,000 --> 00:11:27,000
|
| 539 |
+
the amount of time and effort required to set up an application.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:11:27,000 --> 00:11:33,000
|
| 543 |
+
For example, Spring Boots Auto Configuration feature automatically configures many common components
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:11:33,000 --> 00:11:41,000
|
| 547 |
+
like data sources, web servers and messaging systems based on the dependencies included in the application.
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:11:42,000 --> 00:11:49,000
|
| 551 |
+
This opinionated approach can have several benefits, such as faster development, reduced complexity
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:11:49,000 --> 00:11:51,000
|
| 555 |
+
and improved consistency.
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:11:51,000 --> 00:11:58,000
|
| 559 |
+
Developers can focus on building the application's unique features and business logic rather than spending
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:11:58,000 --> 00:12:02,000
|
| 563 |
+
time on routine tasks like configuration and setup.
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:12:03,000 --> 00:12:11,000
|
| 567 |
+
However, be attentive, the opinionated approach can also be a disadvantage if developers need to deviate
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:12:11,000 --> 00:12:15,000
|
| 571 |
+
from the frameworks predefined conventions.
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:12:15,000 --> 00:12:23,000
|
| 575 |
+
This can require more effort and expertise as developers must understand the frameworks, architecture
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:12:23,000 --> 00:12:27,000
|
| 579 |
+
and implementation details to customize it effectively.
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:12:27,000 --> 00:12:36,000
|
| 583 |
+
That's exactly what I mean when I say that you need to understand how spring works, then it will be
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:12:36,000 --> 00:12:44,000
|
| 587 |
+
easier for you to master spring boot and also level of flexibility of spring boot potentially may become
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:12:44,000 --> 00:12:50,000
|
| 591 |
+
as one of the disadvantages, in my opinion, that we're going to talk about, when we will talk about
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:12:50,000 --> 00:12:52,000
|
| 595 |
+
advantages and disadvantages.
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:12:52,000 --> 00:12:59,000
|
| 599 |
+
An opinionated development approach can be a powerful tool for improving productivity and consistency,
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:12:59,000 --> 00:13:06,000
|
| 603 |
+
but it is important to weigh the benefits and tradeoffs for your specific project and team.
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:13:07,000 --> 00:13:10,000
|
| 607 |
+
We already learned the definition of spring boot.
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:13:10,000 --> 00:13:16,000
|
| 611 |
+
Let's understand when it is more applicable and when it is less applicable.
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:13:16,000 --> 00:13:20,000
|
| 615 |
+
Let's start from learning of when it is good idea to use spring boot.
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:13:21,000 --> 00:13:28,000
|
| 619 |
+
Spring Boot is an excellent choice for developing a wide range of Java based applications, but it is
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:13:28,000 --> 00:13:33,000
|
| 623 |
+
particularly well suited for projects that require rapid development.
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:13:33,000 --> 00:13:41,000
|
| 627 |
+
Spring Boots Opinionated approach to application development along with its easy setup and configuration,
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:13:41,000 --> 00:13:47,000
|
| 631 |
+
make it an ideal choice for rapid prototyping and development of new applications.
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:13:47,000 --> 00:13:49,000
|
| 635 |
+
Microservices.
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:13:49,000 --> 00:13:56,000
|
| 639 |
+
Spring Boot is well suited for developing microservices based architectures as it provides built in
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:13:56,000 --> 00:14:03,000
|
| 643 |
+
support for restful web services, messaging systems and service discovery, among other features.
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:14:04,000 --> 00:14:06,000
|
| 647 |
+
Cloud Native applications.
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:14:06,000 --> 00:14:13,000
|
| 651 |
+
Spring Boot is designed to work well in cloud native environments and includes built in support for
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:14:13,000 --> 00:14:19,000
|
| 655 |
+
containerization and deployment to cloud platforms like Kubernetes and Cloud Foundry.
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:14:20,000 --> 00:14:22,000
|
| 659 |
+
Robustness and scalability.
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:14:22,000 --> 00:14:29,000
|
| 663 |
+
Spring boots built in features for handling data, persistence, caching and security, among other
|
| 664 |
+
|
| 665 |
+
167
|
| 666 |
+
00:14:29,000 --> 00:14:35,000
|
| 667 |
+
things, make it a robust and scalable framework for building complex applications.
|
| 668 |
+
|
| 669 |
+
168
|
| 670 |
+
00:14:36,000 --> 00:14:38,000
|
| 671 |
+
Integration with other technologies.
|
| 672 |
+
|
| 673 |
+
169
|
| 674 |
+
00:14:38,000 --> 00:14:44,000
|
| 675 |
+
Spring Boot is highly extensible and can be easily integrated with a wide range of other technologies
|
| 676 |
+
|
| 677 |
+
170
|
| 678 |
+
00:14:44,000 --> 00:14:52,000
|
| 679 |
+
and frameworks, making it a popular choice for projects that require integration with multiple systems.
|
| 680 |
+
|
| 681 |
+
171
|
| 682 |
+
00:14:52,000 --> 00:14:58,000
|
| 683 |
+
In general, if you are developing Java based applications, it requires rapid development, robustness,
|
| 684 |
+
|
| 685 |
+
172
|
| 686 |
+
00:14:58,000 --> 00:15:01,000
|
| 687 |
+
scalability and integration with other technologies.
|
| 688 |
+
|
| 689 |
+
173
|
| 690 |
+
00:15:01,000 --> 00:15:04,000
|
| 691 |
+
Spring Boot is an excellent choice.
|
| 692 |
+
|
| 693 |
+
174
|
| 694 |
+
00:15:04,000 --> 00:15:10,000
|
| 695 |
+
Additionally, if you are developing microservices based or cloud native applications.
|
| 696 |
+
|
| 697 |
+
175
|
| 698 |
+
00:15:10,000 --> 00:15:16,000
|
| 699 |
+
Spring Boot provides many features and tools that can make the development process much smoother and
|
| 700 |
+
|
| 701 |
+
176
|
| 702 |
+
00:15:16,000 --> 00:15:18,000
|
| 703 |
+
more efficient.
|
| 704 |
+
|
| 705 |
+
177
|
| 706 |
+
00:15:18,000 --> 00:15:25,000
|
| 707 |
+
While Spring Boot is a powerful and flexible framework that is well suited for developing many different
|
| 708 |
+
|
| 709 |
+
178
|
| 710 |
+
00:15:25,000 --> 00:15:32,000
|
| 711 |
+
types of Java applications, there are some cases where it may not be the best choice.
|
| 712 |
+
|
| 713 |
+
179
|
| 714 |
+
00:15:32,000 --> 00:15:37,000
|
| 715 |
+
Here are some situations where you may want to consider using a different framework.
|
| 716 |
+
|
| 717 |
+
180
|
| 718 |
+
00:15:37,000 --> 00:15:39,000
|
| 719 |
+
Small applications.
|
| 720 |
+
|
| 721 |
+
181
|
| 722 |
+
00:15:39,000 --> 00:15:45,000
|
| 723 |
+
If you are developing a small lightweight application that doesn't require a lot of additional features
|
| 724 |
+
|
| 725 |
+
182
|
| 726 |
+
00:15:45,000 --> 00:15:49,000
|
| 727 |
+
or functionality, spring boot may be overkill.
|
| 728 |
+
|
| 729 |
+
183
|
| 730 |
+
00:15:49,000 --> 00:15:54,000
|
| 731 |
+
In this case, a simpler, more lightweight framework may be a better choice.
|
| 732 |
+
|
| 733 |
+
184
|
| 734 |
+
00:15:55,000 --> 00:15:58,000
|
| 735 |
+
Tight control over application configuration.
|
| 736 |
+
|
| 737 |
+
185
|
| 738 |
+
00:15:58,000 --> 00:16:04,000
|
| 739 |
+
While Spring Boot is opinionated, approach to configuration can simplify development.
|
| 740 |
+
|
| 741 |
+
186
|
| 742 |
+
00:16:04,000 --> 00:16:10,000
|
| 743 |
+
It may be a disadvantage if you need tight control over application configuration.
|
| 744 |
+
|
| 745 |
+
187
|
| 746 |
+
00:16:10,000 --> 00:16:16,000
|
| 747 |
+
In this case, a more flexible framework like spring framework may be a better choice.
|
| 748 |
+
|
| 749 |
+
188
|
| 750 |
+
00:16:16,000 --> 00:16:19,000
|
| 751 |
+
Applications with specific performance requirements.
|
| 752 |
+
|
| 753 |
+
189
|
| 754 |
+
00:16:20,000 --> 00:16:27,000
|
| 755 |
+
While Spring Boot is designed to be fast and efficient, there may be cases where more specialized framework
|
| 756 |
+
|
| 757 |
+
190
|
| 758 |
+
00:16:27,000 --> 00:16:30,000
|
| 759 |
+
is required for high performance applications.
|
| 760 |
+
|
| 761 |
+
191
|
| 762 |
+
00:16:31,000 --> 00:16:34,000
|
| 763 |
+
Projects with existing architecture technology stack.
|
| 764 |
+
|
| 765 |
+
192
|
| 766 |
+
00:16:35,000 --> 00:16:41,000
|
| 767 |
+
If you are working on a project that has an existing architecture or technology stack, it may be more
|
| 768 |
+
|
| 769 |
+
193
|
| 770 |
+
00:16:41,000 --> 00:16:45,000
|
| 771 |
+
difficult to integrate Spring Boot into the existing environment.
|
| 772 |
+
|
| 773 |
+
194
|
| 774 |
+
00:16:45,000 --> 00:16:50,000
|
| 775 |
+
In this case, it may be better to stick with the existing tools and technologies.
|
| 776 |
+
|
| 777 |
+
195
|
| 778 |
+
00:16:51,000 --> 00:16:56,000
|
| 779 |
+
Projects that require tight control over application startup time.
|
| 780 |
+
|
| 781 |
+
196
|
| 782 |
+
00:16:56,000 --> 00:17:03,000
|
| 783 |
+
While spring boots, rapid development and easy setup can be a big advantage, it may come at the cost
|
| 784 |
+
|
| 785 |
+
197
|
| 786 |
+
00:17:03,000 --> 00:17:06,000
|
| 787 |
+
of slower startup times for the application.
|
| 788 |
+
|
| 789 |
+
198
|
| 790 |
+
00:17:07,000 --> 00:17:14,000
|
| 791 |
+
If your project requires tight control over application startup time, a more lightweight framework
|
| 792 |
+
|
| 793 |
+
199
|
| 794 |
+
00:17:14,000 --> 00:17:15,000
|
| 795 |
+
may be a better choice.
|
| 796 |
+
|
| 797 |
+
200
|
| 798 |
+
00:17:15,000 --> 00:17:22,000
|
| 799 |
+
Overall, Spring Boot is an excellent choice for many Java based projects, but there may be cases where
|
| 800 |
+
|
| 801 |
+
201
|
| 802 |
+
00:17:22,000 --> 00:17:26,000
|
| 803 |
+
a different framework or approach is more appropriate.
|
| 804 |
+
|
| 805 |
+
202
|
| 806 |
+
00:17:26,000 --> 00:17:33,000
|
| 807 |
+
It is important to evaluate your project requirements carefully and choose the framework that best meets
|
| 808 |
+
|
| 809 |
+
203
|
| 810 |
+
00:17:33,000 --> 00:17:34,000
|
| 811 |
+
your needs.
|
| 812 |
+
|
| 813 |
+
204
|
| 814 |
+
00:17:35,000 --> 00:17:39,000
|
| 815 |
+
Based on what we have learned, let's try to summarize.
|
| 816 |
+
|
| 817 |
+
205
|
| 818 |
+
00:17:39,000 --> 00:17:42,000
|
| 819 |
+
Advantages and disadvantages of Spring Boot.
|
| 820 |
+
|
| 821 |
+
206
|
| 822 |
+
00:17:42,000 --> 00:17:44,000
|
| 823 |
+
Let's start from advantages.
|
| 824 |
+
|
| 825 |
+
207
|
| 826 |
+
00:17:45,000 --> 00:17:50,000
|
| 827 |
+
Spring Boot has numerous advantages that make it a popular choice for Java developers.
|
| 828 |
+
|
| 829 |
+
208
|
| 830 |
+
00:17:50,000 --> 00:17:53,000
|
| 831 |
+
Here are some of the key advantages of Spring boot.
|
| 832 |
+
|
| 833 |
+
209
|
| 834 |
+
00:17:53,000 --> 00:17:56,000
|
| 835 |
+
Rapid Application Development.
|
| 836 |
+
|
| 837 |
+
210
|
| 838 |
+
00:17:56,000 --> 00:18:02,000
|
| 839 |
+
Spring Boot is opinionated approach and easy setup allowed developers to quickly create new applications
|
| 840 |
+
|
| 841 |
+
211
|
| 842 |
+
00:18:02,000 --> 00:18:04,000
|
| 843 |
+
and get them up and running.
|
| 844 |
+
|
| 845 |
+
212
|
| 846 |
+
00:18:05,000 --> 00:18:06,000
|
| 847 |
+
Simplified Configuration.
|
| 848 |
+
|
| 849 |
+
213
|
| 850 |
+
00:18:07,000 --> 00:18:13,000
|
| 851 |
+
Spring Boots Auto Configuration Feature simplifies the configuration process, reducing the amount of
|
| 852 |
+
|
| 853 |
+
214
|
| 854 |
+
00:18:13,000 --> 00:18:16,000
|
| 855 |
+
boilerplate code that developers need to write.
|
| 856 |
+
|
| 857 |
+
215
|
| 858 |
+
00:18:17,000 --> 00:18:18,000
|
| 859 |
+
Embedded Web Server.
|
| 860 |
+
|
| 861 |
+
216
|
| 862 |
+
00:18:18,000 --> 00:18:25,000
|
| 863 |
+
Spring Boot includes an embedded web server, which allows developers to easily create web based applications
|
| 864 |
+
|
| 865 |
+
217
|
| 866 |
+
00:18:25,000 --> 00:18:29,000
|
| 867 |
+
without having to configure and manage an external web server.
|
| 868 |
+
|
| 869 |
+
218
|
| 870 |
+
00:18:30,000 --> 00:18:31,000
|
| 871 |
+
Dependency Management.
|
| 872 |
+
|
| 873 |
+
219
|
| 874 |
+
00:18:31,000 --> 00:18:38,000
|
| 875 |
+
Spring Boots Dependency Management System automatically manages versions and conflicts, making it easier
|
| 876 |
+
|
| 877 |
+
220
|
| 878 |
+
00:18:38,000 --> 00:18:43,000
|
| 879 |
+
for developers to manage the dependencies required by an application.
|
| 880 |
+
|
| 881 |
+
221
|
| 882 |
+
00:18:43,000 --> 00:18:45,000
|
| 883 |
+
Automatic configuration.
|
| 884 |
+
|
| 885 |
+
222
|
| 886 |
+
00:18:45,000 --> 00:18:52,000
|
| 887 |
+
Spring Boot automatically configures common components such as data sources, messaging systems and
|
| 888 |
+
|
| 889 |
+
223
|
| 890 |
+
00:18:52,000 --> 00:18:57,000
|
| 891 |
+
web servers based on the dependencies included in an application.
|
| 892 |
+
|
| 893 |
+
224
|
| 894 |
+
00:18:57,000 --> 00:18:58,000
|
| 895 |
+
Actuator.
|
| 896 |
+
|
| 897 |
+
225
|
| 898 |
+
00:18:58,000 --> 00:19:06,000
|
| 899 |
+
Spring boot actuator provides a set of endpoints and tools that make it easy to monitor and manage an
|
| 900 |
+
|
| 901 |
+
226
|
| 902 |
+
00:19:06,000 --> 00:19:13,000
|
| 903 |
+
application at runtime, including health checks, metrics and other diagnostic tools.
|
| 904 |
+
|
| 905 |
+
227
|
| 906 |
+
00:19:13,000 --> 00:19:15,000
|
| 907 |
+
Microservices.
|
| 908 |
+
|
| 909 |
+
228
|
| 910 |
+
00:19:15,000 --> 00:19:22,000
|
| 911 |
+
Spring Boot is well suited for developing microservices based architecture as it provides built in support
|
| 912 |
+
|
| 913 |
+
229
|
| 914 |
+
00:19:22,000 --> 00:19:27,000
|
| 915 |
+
for restful web services, messaging systems and service discovery.
|
| 916 |
+
|
| 917 |
+
230
|
| 918 |
+
00:19:28,000 --> 00:19:32,000
|
| 919 |
+
Cloud Native Spring Boot is designed to work well in a cloud.
|
| 920 |
+
|
| 921 |
+
231
|
| 922 |
+
00:19:32,000 --> 00:19:37,000
|
| 923 |
+
Native environments with built in support for containerization and deployment to cloud platforms like
|
| 924 |
+
|
| 925 |
+
232
|
| 926 |
+
00:19:37,000 --> 00:19:39,000
|
| 927 |
+
Kubernetes and Cloud Foundry.
|
| 928 |
+
|
| 929 |
+
233
|
| 930 |
+
00:19:40,000 --> 00:19:42,000
|
| 931 |
+
Integration with other technologies.
|
| 932 |
+
|
| 933 |
+
234
|
| 934 |
+
00:19:42,000 --> 00:19:49,000
|
| 935 |
+
Spring Boot is highly extensible and can be easily integrated with a wide range of other technologies
|
| 936 |
+
|
| 937 |
+
235
|
| 938 |
+
00:19:49,000 --> 00:19:55,000
|
| 939 |
+
and frameworks, making it a popular choice for projects that require integration with multiple systems.
|
| 940 |
+
|
| 941 |
+
236
|
| 942 |
+
00:19:56,000 --> 00:20:01,000
|
| 943 |
+
So as you can see, this is a summary of what we have learned already.
|
| 944 |
+
|
| 945 |
+
237
|
| 946 |
+
00:20:02,000 --> 00:20:08,000
|
| 947 |
+
While Spring Boot has numerous advantages, there are also some potential disadvantages to consider
|
| 948 |
+
|
| 949 |
+
238
|
| 950 |
+
00:20:08,000 --> 00:20:12,000
|
| 951 |
+
when choosing whether to use it for your project or not.
|
| 952 |
+
|
| 953 |
+
239
|
| 954 |
+
00:20:12,000 --> 00:20:15,000
|
| 955 |
+
Here are some of the key disadvantages of spring boot.
|
| 956 |
+
|
| 957 |
+
240
|
| 958 |
+
00:20:16,000 --> 00:20:18,000
|
| 959 |
+
Limited flexibility.
|
| 960 |
+
|
| 961 |
+
241
|
| 962 |
+
00:20:18,000 --> 00:20:19,000
|
| 963 |
+
As we already discussed.
|
| 964 |
+
|
| 965 |
+
242
|
| 966 |
+
00:20:19,000 --> 00:20:26,000
|
| 967 |
+
But just to summarize, while spring Boots opinionated approach can simplify development, it can also
|
| 968 |
+
|
| 969 |
+
243
|
| 970 |
+
00:20:26,000 --> 00:20:33,000
|
| 971 |
+
limit flexibility, making it more difficult to customize the application to meet specific requirements.
|
| 972 |
+
|
| 973 |
+
244
|
| 974 |
+
00:20:33,000 --> 00:20:35,000
|
| 975 |
+
Learning Curve.
|
| 976 |
+
|
| 977 |
+
245
|
| 978 |
+
00:20:35,000 --> 00:20:42,000
|
| 979 |
+
While Spring Boot is designed to be easy to use, there is still a learning curve involved, particularly
|
| 980 |
+
|
| 981 |
+
246
|
| 982 |
+
00:20:42,000 --> 00:20:46,000
|
| 983 |
+
for developers who are new to the spring ecosystem.
|
| 984 |
+
|
| 985 |
+
247
|
| 986 |
+
00:20:46,000 --> 00:20:48,000
|
| 987 |
+
Increased application size.
|
| 988 |
+
|
| 989 |
+
248
|
| 990 |
+
00:20:49,000 --> 00:20:56,000
|
| 991 |
+
Spring boots, extensive set of features and auto configuration can lead to larger application sizes,
|
| 992 |
+
|
| 993 |
+
249
|
| 994 |
+
00:20:56,000 --> 00:21:02,000
|
| 995 |
+
which may be a disadvantage for applications with strict size requirements.
|
| 996 |
+
|
| 997 |
+
250
|
| 998 |
+
00:21:03,000 --> 00:21:10,000
|
| 999 |
+
Overhead Spring Boot's, auto configuration and other features can introduce some additional overhead,
|
| 1000 |
+
|
| 1001 |
+
251
|
| 1002 |
+
00:21:10,000 --> 00:21:15,000
|
| 1003 |
+
which may be a disadvantage for applications with strict performance requirements.
|
| 1004 |
+
|
| 1005 |
+
252
|
| 1006 |
+
00:21:16,000 --> 00:21:18,000
|
| 1007 |
+
Opinionated approach.
|
| 1008 |
+
|
| 1009 |
+
253
|
| 1010 |
+
00:21:18,000 --> 00:21:24,000
|
| 1011 |
+
While spring boots opinionated approach can be a benefit for developers who are looking for a quick
|
| 1012 |
+
|
| 1013 |
+
254
|
| 1014 |
+
00:21:24,000 --> 00:21:31,000
|
| 1015 |
+
and easy way to build an application, it can also be a disadvantage for developers who prefer more
|
| 1016 |
+
|
| 1017 |
+
255
|
| 1018 |
+
00:21:31,000 --> 00:21:36,000
|
| 1019 |
+
control over their application architecture and implementation.
|
| 1020 |
+
|
| 1021 |
+
256
|
| 1022 |
+
00:21:36,000 --> 00:21:38,000
|
| 1023 |
+
Steep dependency.
|
| 1024 |
+
|
| 1025 |
+
257
|
| 1026 |
+
00:21:39,000 --> 00:21:46,000
|
| 1027 |
+
Spring boot dependency management system can result in a deep Iraqi of dependencies, which can be difficult
|
| 1028 |
+
|
| 1029 |
+
258
|
| 1030 |
+
00:21:46,000 --> 00:21:51,000
|
| 1031 |
+
to manage and may cause conflicts or compatibility issues.
|
| 1032 |
+
|
| 1033 |
+
259
|
| 1034 |
+
00:21:51,000 --> 00:21:53,000
|
| 1035 |
+
Complexity for small projects.
|
| 1036 |
+
|
| 1037 |
+
260
|
| 1038 |
+
00:21:53,000 --> 00:22:01,000
|
| 1039 |
+
For very small projects that don't require many features, Spring Boot may be overkill and introduce
|
| 1040 |
+
|
| 1041 |
+
261
|
| 1042 |
+
00:22:01,000 --> 00:22:03,000
|
| 1043 |
+
unnecessary complexity.
|
| 1044 |
+
|
| 1045 |
+
262
|
| 1046 |
+
00:22:03,000 --> 00:22:07,000
|
| 1047 |
+
Basically, that's all what I wanted to share with you today.
|
| 1048 |
+
|
| 1049 |
+
263
|
| 1050 |
+
00:22:07,000 --> 00:22:11,000
|
| 1051 |
+
Let's recap what we have learned in the video.
|
| 1052 |
+
|
| 1053 |
+
264
|
| 1054 |
+
00:22:11,000 --> 00:22:14,000
|
| 1055 |
+
We learned what a spring boot is.
|
| 1056 |
+
|
| 1057 |
+
265
|
| 1058 |
+
00:22:14,000 --> 00:22:16,000
|
| 1059 |
+
We learned its key features.
|
| 1060 |
+
|
| 1061 |
+
266
|
| 1062 |
+
00:22:17,000 --> 00:22:21,000
|
| 1063 |
+
I explained what an opinionated development approach is.
|
| 1064 |
+
|
| 1065 |
+
267
|
| 1066 |
+
00:22:21,000 --> 00:22:27,000
|
| 1067 |
+
Now you know when to use spring boot and when not to use spring boot.
|
| 1068 |
+
|
| 1069 |
+
268
|
| 1070 |
+
00:22:27,000 --> 00:22:32,000
|
| 1071 |
+
And at the end of the lesson, we learned its advantages and disadvantages.
|
| 1072 |
+
|
| 1073 |
+
269
|
| 1074 |
+
00:22:33,000 --> 00:22:35,000
|
| 1075 |
+
That's it for this lesson.
|
| 1076 |
+
|
| 1077 |
+
270
|
| 1078 |
+
00:22:35,000 --> 00:22:37,000
|
| 1079 |
+
Thanks a lot for your attention.
|
| 1080 |
+
|
| 1081 |
+
271
|
| 1082 |
+
00:22:37,000 --> 00:22:40,000
|
| 1083 |
+
Have a great day and see you in the next lesson.
|
| 1084 |
+
|
92 - Spring Boot/002 Source-code-of-the-first-Spring-Boot-project-from-the-lesson-commit-with-changes-.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/AndriiPiatakha/java-learnit-spring-boot/commit/ed97cff607917d923b693146b5fcdc08d507d422
|
92 - Spring Boot/002 Spring-Initializr-Tool.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://start.spring.io/
|
92 - Spring Boot/002 The First Spring Boot Project_en.srt
ADDED
|
@@ -0,0 +1,876 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:05,000 --> 00:00:10,000
|
| 3 |
+
Hello, dear students, we already learned what a spring boot is in the previous lesson.
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:10,000 --> 00:00:14,000
|
| 7 |
+
And in this lesson, we are going to have practical activities.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:14,000 --> 00:00:19,000
|
| 11 |
+
We are going to create our first spring boot project and run it.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:19,000 --> 00:00:26,000
|
| 15 |
+
We are going to start this lesson from London Spring Initializer two because we are going to use it
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:26,000 --> 00:00:28,000
|
| 19 |
+
for the Spring Boot project generation.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:29,000 --> 00:00:36,000
|
| 23 |
+
In total, I'm going to show you two main ways to generate your first spring boot project where spring
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:36,000 --> 00:00:41,000
|
| 27 |
+
initializer web tool and directly in your eclipse IDE.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:41,000 --> 00:00:47,000
|
| 31 |
+
We will learn these two ways and will set up projects in the IDE for further development.
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:48,000 --> 00:00:51,000
|
| 35 |
+
And we are going to have a lot of practical activity today.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:52,000 --> 00:00:57,000
|
| 39 |
+
We will create our first spring MVC controller in our first spring boot application.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:57,000 --> 00:00:59,000
|
| 43 |
+
Let's start our lesson.
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:01:00,000 --> 00:01:04,000
|
| 47 |
+
The first thing that I want to demo you is spring initializer tool.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:01:04,000 --> 00:01:10,000
|
| 51 |
+
Let me explain what it is, because we are going to use this tool today in the lesson to create our
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:01:10,000 --> 00:01:12,000
|
| 55 |
+
first spring boot project.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:01:12,000 --> 00:01:20,000
|
| 59 |
+
Spring Initializer is a web based tool provided by the Spring Team to help bootstrap and generate spring
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:01:20,000 --> 00:01:21,000
|
| 63 |
+
boot projects with ease.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:01:21,000 --> 00:01:28,000
|
| 67 |
+
It simplifies the process of setting up a new spring boot project by generating a project structure
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:01:28,000 --> 00:01:34,000
|
| 71 |
+
with the required dependencies and configurations based on your selections.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:01:35,000 --> 00:01:41,000
|
| 75 |
+
Key features of spring initializer include project customization.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:01:41,000 --> 00:01:49,000
|
| 79 |
+
Spring Initializer allows you to customize various aspects of your project, such as project, metadata,
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:01:49,000 --> 00:01:52,000
|
| 83 |
+
dependencies and build systems.
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:01:52,000 --> 00:01:56,000
|
| 87 |
+
You can specify the project's group and artifact name.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:01:56,000 --> 00:02:05,000
|
| 91 |
+
Select the desired spring boot version and add dependencies like Spring Web, spring data, JPA security
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:02:05,000 --> 00:02:07,000
|
| 95 |
+
testing frameworks and more.
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:02:08,000 --> 00:02:10,000
|
| 99 |
+
Starter dependencies.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:02:10,000 --> 00:02:19,000
|
| 103 |
+
Spring initializer leverages starter dependencies which are opinionated dependency descriptors to simplify
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:02:19,000 --> 00:02:24,000
|
| 107 |
+
the inclusion of common libraries and frameworks in your project.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:02:24,000 --> 00:02:30,000
|
| 111 |
+
Starters provide a convenient way to add functionality to your spring boot project by automatically
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:02:30,000 --> 00:02:34,000
|
| 115 |
+
configuring the necessary dependencies and boilerplate code.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:02:35,000 --> 00:02:36,000
|
| 119 |
+
Configuration options.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:02:37,000 --> 00:02:43,000
|
| 123 |
+
The tool offers additional configuration options for your project, including choosing the Build System
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:02:43,000 --> 00:02:51,000
|
| 127 |
+
MAVEN or Gradle Java version, packaging format, Java and more.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:02:51,000 --> 00:02:59,000
|
| 131 |
+
It also allows you to specify advanced settings like choosing a specific spring boot version or enabling
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:02:59,000 --> 00:03:01,000
|
| 135 |
+
specific features like Kotlin support.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:03:02,000 --> 00:03:04,000
|
| 139 |
+
Project generation.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:03:04,000 --> 00:03:11,000
|
| 143 |
+
Once you have customized your project settings, Spring Initializer generates a downloadable project
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:03:11,000 --> 00:03:17,000
|
| 147 |
+
archive that contains the project structure and the necessary configuration files.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:03:17,000 --> 00:03:25,000
|
| 151 |
+
You can choose to download the project as zip file or directly import it into your favorite IDE.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:03:25,000 --> 00:03:28,000
|
| 155 |
+
Integration with Ides.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:03:28,000 --> 00:03:35,000
|
| 159 |
+
Spring initializer provides seamless integration with popular IDES, making it easier to create and
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:03:35,000 --> 00:03:38,000
|
| 163 |
+
import projects directly from the IDE.
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:03:38,000 --> 00:03:42,000
|
| 167 |
+
Supported ides include IntelliJ Eclipse.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:03:42,000 --> 00:03:49,000
|
| 171 |
+
The integration helps you skip manual project setup steps and jump straight into development.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:03:50,000 --> 00:03:56,000
|
| 175 |
+
A little bit later today during the demo, I'm going to show you which extension you can install into
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:03:56,000 --> 00:04:02,000
|
| 179 |
+
your eclipse IDE in order to generate spring boot project directly from the IDE.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:04:02,000 --> 00:04:09,000
|
| 183 |
+
As you can see, spring initializer simplifies the process of creating spring boot projects by providing
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:04:09,000 --> 00:04:17,000
|
| 187 |
+
an intuitive web based interface, customizable options and a streamlined project generation mechanism.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:04:17,000 --> 00:04:25,000
|
| 191 |
+
It helps developers get started quickly with Spring Boot and reduces the initial setup overhead, allowing
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:04:25,000 --> 00:04:28,000
|
| 195 |
+
them to focus on building their applications.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:04:29,000 --> 00:04:33,000
|
| 199 |
+
As I already said, this is going to be practical lesson.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:04:33,000 --> 00:04:38,000
|
| 203 |
+
So let me start screen sharing and we will jump directly to practical examples.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:04:39,000 --> 00:04:43,000
|
| 207 |
+
So you already learned what a spring initializer tool is.
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:04:43,000 --> 00:04:45,000
|
| 211 |
+
Let me show you how to work with it.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:04:45,000 --> 00:04:53,000
|
| 215 |
+
On practice, you can get access to it using this URL, I will leave a link in attachments to the video.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:04:53,000 --> 00:04:55,000
|
| 219 |
+
Here we have user friendly UI.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:04:56,000 --> 00:05:00,000
|
| 223 |
+
Let me comment on some UI elements and key labels here.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:05:01,000 --> 00:05:02,000
|
| 227 |
+
Project.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:05:02,000 --> 00:05:09,000
|
| 231 |
+
It defines the kind of project we can create is a MAVEN project or GRADLE project.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:05:09,000 --> 00:05:15,000
|
| 235 |
+
If you are a student of my Java from zero to first job course and you watched the section about automation
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:05:15,000 --> 00:05:21,000
|
| 239 |
+
build tools, then you already know my opinion and why I select Maven.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:05:21,000 --> 00:05:26,000
|
| 243 |
+
If you want to learn more, you can check the relevant section in my course Java from zero to first
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:05:26,000 --> 00:05:29,000
|
| 247 |
+
Job language.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:05:29,000 --> 00:05:35,000
|
| 251 |
+
Spring Initializer provides the choice among three languages Java, Kotlin and Groovy.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:05:36,000 --> 00:05:43,000
|
| 255 |
+
Java is selected by default and in this lesson we will not discuss which language is better.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:05:43,000 --> 00:05:49,000
|
| 259 |
+
You're welcome to select the one you like the most, but I keep Java selected.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:05:49,000 --> 00:05:50,000
|
| 263 |
+
Spring boot.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:05:50,000 --> 00:05:53,000
|
| 267 |
+
We can select the spring boot version.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:05:54,000 --> 00:05:55,000
|
| 271 |
+
Project metadata.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:05:55,000 --> 00:06:01,000
|
| 275 |
+
It contains information related to the project, such as group, artifact, etcetera.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:06:02,000 --> 00:06:06,000
|
| 279 |
+
Usually group is used in package name.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:06:06,000 --> 00:06:11,000
|
| 283 |
+
Artifact denotes the application name and also used in package name.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:06:11,000 --> 00:06:20,000
|
| 287 |
+
I will change group name to the common name that I use in my course and also set artifact name to reflect
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:06:20,000 --> 00:06:22,000
|
| 291 |
+
the goal of this project.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:06:23,000 --> 00:06:24,000
|
| 295 |
+
Name.
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:06:24,000 --> 00:06:28,000
|
| 299 |
+
It is the same as artifact description.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:06:28,000 --> 00:06:34,000
|
| 303 |
+
In the description field, we can write a description of the project package name.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:06:34,000 --> 00:06:38,000
|
| 307 |
+
Usually it is a combination of our group name and artifact name.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:06:38,000 --> 00:06:42,000
|
| 311 |
+
If you are familiar with Maven, you should be aware about such practice.
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:06:43,000 --> 00:06:44,000
|
| 315 |
+
Packaging.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:06:44,000 --> 00:06:47,000
|
| 319 |
+
We can select the packaging of the project.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:06:47,000 --> 00:06:50,000
|
| 323 |
+
We can choose either jar or war.
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:06:50,000 --> 00:06:57,000
|
| 327 |
+
I select Jar because one of the advantages of the spring boot is to have just Java installed on your
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:06:57,000 --> 00:07:05,000
|
| 331 |
+
computer in order to run web application and you can run Jar archives with Java Command.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:07:05,000 --> 00:07:06,000
|
| 335 |
+
Java.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:07:07,000 --> 00:07:11,000
|
| 339 |
+
We can select the JVM version which we want to use.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:07:11,000 --> 00:07:17,000
|
| 343 |
+
We'll use Java 11 version because it is latest long term support version.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:07:17,000 --> 00:07:25,000
|
| 347 |
+
I know that Oracle releases new version of Java each six months, but even despite this crazy enumeration,
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:07:25,000 --> 00:07:32,000
|
| 351 |
+
Steal Java Version eight is the most popular around the world, and Java version 11 is the latest long
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:07:32,000 --> 00:07:34,000
|
| 355 |
+
term support version.
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:07:34,000 --> 00:07:40,000
|
| 359 |
+
If you want to learn more about versions and what is long term support version, please refer to my
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:07:40,000 --> 00:07:42,000
|
| 363 |
+
course Java from zero to first job.
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:07:43,000 --> 00:07:49,000
|
| 367 |
+
This is a lesson about Java installation where I explained more about Java versions.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:07:50,000 --> 00:07:51,000
|
| 371 |
+
Dependencies.
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:07:51,000 --> 00:07:56,000
|
| 375 |
+
Dependencies are the collection of artifacts that we can add to our project.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:07:57,000 --> 00:08:01,000
|
| 379 |
+
There are multiple dependencies you can choose from on this stage.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:08:01,000 --> 00:08:05,000
|
| 383 |
+
Don't worry, you can always add dependencies later.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:08:05,000 --> 00:08:11,000
|
| 387 |
+
For the sake of the demo, I just added spring boot dev tools and spring lab.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:08:11,000 --> 00:08:19,000
|
| 391 |
+
Spring lab is important dependency in order to have embedded tomcat web server and the spring boot dev
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:08:19,000 --> 00:08:27,000
|
| 395 |
+
tools is a dependency that enhance development experience like fast application restarts and life reload
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:08:27,000 --> 00:08:31,000
|
| 399 |
+
without need to recompile and restart application.
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:08:32,000 --> 00:08:36,000
|
| 403 |
+
You can click Explore button to review the source code.
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:08:36,000 --> 00:08:43,000
|
| 407 |
+
Just in case you want to configure the project manually and you want to copy and paste content of files
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:08:43,000 --> 00:08:47,000
|
| 411 |
+
or or you just want to take a look at the structure.
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:08:47,000 --> 00:08:51,000
|
| 415 |
+
Anyway, that is not something what we are interested in right now.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:08:51,000 --> 00:08:56,000
|
| 419 |
+
Instead, let's close this view and click Generate button.
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:08:56,000 --> 00:08:58,000
|
| 423 |
+
It will download a zip archive.
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:08:59,000 --> 00:09:07,000
|
| 427 |
+
The next thing what we have to do is to extract the project from archive and import it into our IDE.
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:09:08,000 --> 00:09:13,000
|
| 431 |
+
For example, I extracted the content of the archive in the workspace folder.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:09:13,000 --> 00:09:15,000
|
| 435 |
+
Now let me open the eclipse ide.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:09:16,000 --> 00:09:25,000
|
| 439 |
+
I click file import existing Maven project and I select the project that was generated by Spring Initializer
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:09:25,000 --> 00:09:26,000
|
| 443 |
+
Tool.
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:09:26,000 --> 00:09:28,000
|
| 447 |
+
And that's it.
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:09:28,000 --> 00:09:33,000
|
| 451 |
+
I already imported Spring Boot demo project into Eclipse IDE.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:09:33,000 --> 00:09:38,000
|
| 455 |
+
That's why I can see a conflict in the namespace here.
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:09:39,000 --> 00:09:40,000
|
| 459 |
+
But you can do this.
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:09:40,000 --> 00:09:43,000
|
| 463 |
+
Similar steps and everything will be okay for you.
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:09:44,000 --> 00:09:49,000
|
| 467 |
+
That's how you can generate your first spring boot project with spring initializer tool.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:09:50,000 --> 00:09:55,000
|
| 471 |
+
Now let me show you another way to generate your first spring boot project directly from the Eclipse
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:09:55,000 --> 00:09:56,000
|
| 475 |
+
IDE.
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:09:56,000 --> 00:10:01,000
|
| 479 |
+
First of all, we need to install extension into our eclipse.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:10:01,000 --> 00:10:02,000
|
| 483 |
+
Click help.
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:10:03,000 --> 00:10:08,000
|
| 487 |
+
Then eclipse marketplace in the search bar type spring tools.
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:10:14,000 --> 00:10:20,000
|
| 491 |
+
In this list, I select Spring Tools for and click install button.
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:10:20,000 --> 00:10:23,000
|
| 495 |
+
Taking into account it is already installed.
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:10:23,000 --> 00:10:29,000
|
| 499 |
+
I don't have installed button, but you are going to see install button here.
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:10:29,000 --> 00:10:32,000
|
| 503 |
+
Just click it and follow the instructions.
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:10:33,000 --> 00:10:37,000
|
| 507 |
+
After installation you would be asked to restart the eclipse.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:10:37,000 --> 00:10:40,000
|
| 511 |
+
Follow these instructions and restart it.
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:10:41,000 --> 00:10:49,000
|
| 515 |
+
Once it is installed, you can click file new and just search for spring starter project.
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:10:49,000 --> 00:10:56,000
|
| 519 |
+
And here you can see literally the similar configurations that we saw on the web application.
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:10:56,000 --> 00:11:04,000
|
| 523 |
+
Let's configure the application in the similar way, but let's just change the artifact name and add
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:11:04,000 --> 00:11:10,000
|
| 527 |
+
two at the end of the artifact name in order to not have conflicts in names.
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:11:11,000 --> 00:11:15,000
|
| 531 |
+
On the next page you can configure dependencies and spring boot version.
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:11:16,000 --> 00:11:25,000
|
| 535 |
+
Let's add spring boot devtools and Spring Web similarly to the way we did when we generated our application
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:11:25,000 --> 00:11:27,000
|
| 539 |
+
where spring initializer web app.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:11:28,000 --> 00:11:32,000
|
| 543 |
+
Then just click, finish and project will be generated.
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:11:32,000 --> 00:11:34,000
|
| 547 |
+
It is super easy.
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:11:34,000 --> 00:11:35,000
|
| 551 |
+
Don't you think so?
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:11:36,000 --> 00:11:37,000
|
| 555 |
+
So what to do now?
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:11:37,000 --> 00:11:40,000
|
| 559 |
+
Let's just run it and see.
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:11:40,000 --> 00:11:47,000
|
| 563 |
+
Anyway, I recommend you to install Spring Tools because it adds a lot of different integrations for
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:11:47,000 --> 00:11:49,000
|
| 567 |
+
spring boot applications.
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:11:49,000 --> 00:11:56,000
|
| 571 |
+
For example, you don't need to build your application where console in order to run it because you
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:11:56,000 --> 00:12:00,000
|
| 575 |
+
have nice button run as spring boot app.
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:12:00,000 --> 00:12:07,000
|
| 579 |
+
By default, spring application is deployed in the root of the server and available at localhost at
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:12:07,000 --> 00:12:12,000
|
| 583 |
+
port 8080 the default port of tomcat server.
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:12:12,000 --> 00:12:15,000
|
| 587 |
+
Let's check it in the browser.
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:12:15,000 --> 00:12:19,000
|
| 591 |
+
Taking into account we don't have any mappings or resources configured.
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:12:19,000 --> 00:12:27,000
|
| 595 |
+
We see error page, but the fact that server replies us with the error page is enough to understand
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:12:27,000 --> 00:12:30,000
|
| 599 |
+
that our application is up and running.
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:12:30,000 --> 00:12:36,000
|
| 603 |
+
Congratulations you created and started your first spring boot application.
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:12:37,000 --> 00:12:44,000
|
| 607 |
+
And in order to make this lesson complete, let's create at least one simple controller that would redirect
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:12:44,000 --> 00:12:50,000
|
| 611 |
+
us to the home page, and we'll get rid of this error page specially for this lesson.
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:12:50,000 --> 00:12:56,000
|
| 615 |
+
I already prepared source code example in attachments to the video lesson.
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:12:56,000 --> 00:13:02,000
|
| 619 |
+
You can find the reference to the git repository where you can find the source code of example that
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:13:02,000 --> 00:13:04,000
|
| 623 |
+
I prepared for you.
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:13:04,000 --> 00:13:12,000
|
| 627 |
+
You can just clone the repository locally and run it on your computer or explore the source code in
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:13:12,000 --> 00:13:13,000
|
| 631 |
+
details.
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:13:13,000 --> 00:13:17,000
|
| 635 |
+
And right now I will walk you through the prepared source code examples.
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:13:18,000 --> 00:13:25,000
|
| 639 |
+
In case you watched my previous lessons about spring and you are familiar with spring MVC, there will
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:13:25,000 --> 00:13:27,000
|
| 643 |
+
be nothing new for you.
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:13:27,000 --> 00:13:34,000
|
| 647 |
+
In case you are not familiar with spring MVC, then, like I already said in the first theoretical lesson
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:13:34,000 --> 00:13:40,000
|
| 651 |
+
about Spring Boot, make sure you learn spring framework first before learning Spring Boot.
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:13:40,000 --> 00:13:45,000
|
| 655 |
+
You can check my lessons about spring MVC in my course Java from zero to first job.
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:13:46,000 --> 00:13:50,000
|
| 659 |
+
So let's start an overview of the example.
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:13:50,000 --> 00:13:51,000
|
| 663 |
+
Here it is.
|
| 664 |
+
|
| 665 |
+
167
|
| 666 |
+
00:13:52,000 --> 00:13:58,000
|
| 667 |
+
I added simple controller in controllers package that is called Home Controller.
|
| 668 |
+
|
| 669 |
+
168
|
| 670 |
+
00:13:58,000 --> 00:14:02,000
|
| 671 |
+
I configured mapping using get mapping annotation.
|
| 672 |
+
|
| 673 |
+
169
|
| 674 |
+
00:14:03,000 --> 00:14:09,000
|
| 675 |
+
The next thing in application properties that are located in the resources source folder.
|
| 676 |
+
|
| 677 |
+
170
|
| 678 |
+
00:14:10,000 --> 00:14:18,000
|
| 679 |
+
I added few details for the view resolver, namely I specified spring MVC view prefix and suffix.
|
| 680 |
+
|
| 681 |
+
171
|
| 682 |
+
00:14:18,000 --> 00:14:19,000
|
| 683 |
+
That's it.
|
| 684 |
+
|
| 685 |
+
172
|
| 686 |
+
00:14:20,000 --> 00:14:26,000
|
| 687 |
+
I don't need to configure view resolver separately like we did in spring MVC because Spring Boot will
|
| 688 |
+
|
| 689 |
+
173
|
| 690 |
+
00:14:26,000 --> 00:14:32,000
|
| 691 |
+
configure view resolver automatically based on our configurations provided.
|
| 692 |
+
|
| 693 |
+
174
|
| 694 |
+
00:14:32,000 --> 00:14:40,000
|
| 695 |
+
In general, this file application properties we are going to use a lot in order to pass required configuration
|
| 696 |
+
|
| 697 |
+
175
|
| 698 |
+
00:14:40,000 --> 00:14:41,000
|
| 699 |
+
for the spring boot.
|
| 700 |
+
|
| 701 |
+
176
|
| 702 |
+
00:14:42,000 --> 00:14:45,000
|
| 703 |
+
Also I added web app folder.
|
| 704 |
+
|
| 705 |
+
177
|
| 706 |
+
00:14:45,000 --> 00:14:52,000
|
| 707 |
+
I believe you remember that all our web resources should be placed in the separate folder by default
|
| 708 |
+
|
| 709 |
+
178
|
| 710 |
+
00:14:52,000 --> 00:14:53,000
|
| 711 |
+
in spring boot.
|
| 712 |
+
|
| 713 |
+
179
|
| 714 |
+
00:14:53,000 --> 00:15:00,000
|
| 715 |
+
You should put your web resources in web app folder under src main sub folder.
|
| 716 |
+
|
| 717 |
+
180
|
| 718 |
+
00:15:01,000 --> 00:15:04,000
|
| 719 |
+
I created here Web-inf folder.
|
| 720 |
+
|
| 721 |
+
181
|
| 722 |
+
00:15:04,000 --> 00:15:11,000
|
| 723 |
+
And we also already learned that content of the Web-inf is not accessible directly from the outside
|
| 724 |
+
|
| 725 |
+
182
|
| 726 |
+
00:15:11,000 --> 00:15:13,000
|
| 727 |
+
of the application.
|
| 728 |
+
|
| 729 |
+
183
|
| 730 |
+
00:15:13,000 --> 00:15:21,000
|
| 731 |
+
That's why clients won't be able to access the resource in the web in folder directly.
|
| 732 |
+
|
| 733 |
+
184
|
| 734 |
+
00:15:21,000 --> 00:15:29,000
|
| 735 |
+
Instead, according to the MVC pattern, client will be able to access only the controller and on the
|
| 736 |
+
|
| 737 |
+
185
|
| 738 |
+
00:15:29,000 --> 00:15:36,000
|
| 739 |
+
server side controller will forward the request to the resource in the web in folder if needed.
|
| 740 |
+
|
| 741 |
+
186
|
| 742 |
+
00:15:37,000 --> 00:15:41,000
|
| 743 |
+
And here in Views folder, I created two JSP files.
|
| 744 |
+
|
| 745 |
+
187
|
| 746 |
+
00:15:42,000 --> 00:15:43,000
|
| 747 |
+
The first one is home.
|
| 748 |
+
|
| 749 |
+
188
|
| 750 |
+
00:15:43,000 --> 00:15:52,000
|
| 751 |
+
It contains simple HTML markup and just the text to indicate that we are on the home page and error
|
| 752 |
+
|
| 753 |
+
189
|
| 754 |
+
00:15:52,000 --> 00:15:53,000
|
| 755 |
+
page.
|
| 756 |
+
|
| 757 |
+
190
|
| 758 |
+
00:15:53,000 --> 00:16:01,000
|
| 759 |
+
Here request will be forwarded in case of any errors, even despite the fact we didn't create any specific
|
| 760 |
+
|
| 761 |
+
191
|
| 762 |
+
00:16:01,000 --> 00:16:04,000
|
| 763 |
+
controller or exception handler.
|
| 764 |
+
|
| 765 |
+
192
|
| 766 |
+
00:16:04,000 --> 00:16:11,000
|
| 767 |
+
There is a spring boot internal error handling mechanism which is automatically applied if no custom
|
| 768 |
+
|
| 769 |
+
193
|
| 770 |
+
00:16:11,000 --> 00:16:13,000
|
| 771 |
+
error handling is defined.
|
| 772 |
+
|
| 773 |
+
194
|
| 774 |
+
00:16:13,000 --> 00:16:19,000
|
| 775 |
+
Again, this is something what we talked about in the first lesson about Spring Boot.
|
| 776 |
+
|
| 777 |
+
195
|
| 778 |
+
00:16:19,000 --> 00:16:22,000
|
| 779 |
+
Convention over configuration.
|
| 780 |
+
|
| 781 |
+
196
|
| 782 |
+
00:16:22,000 --> 00:16:27,000
|
| 783 |
+
And during the course we are going to learn such conventions and agreements.
|
| 784 |
+
|
| 785 |
+
197
|
| 786 |
+
00:16:27,000 --> 00:16:34,000
|
| 787 |
+
In a minute I'm going to show you how Error page is resolved and just in case I will make an overview
|
| 788 |
+
|
| 789 |
+
198
|
| 790 |
+
00:16:34,000 --> 00:16:36,000
|
| 791 |
+
of POM XML.
|
| 792 |
+
|
| 793 |
+
199
|
| 794 |
+
00:16:36,000 --> 00:16:43,000
|
| 795 |
+
But in case you selected spring web tools during the project generation, you should be good and nothing
|
| 796 |
+
|
| 797 |
+
200
|
| 798 |
+
00:16:43,000 --> 00:16:45,000
|
| 799 |
+
should be added manually on top of that.
|
| 800 |
+
|
| 801 |
+
201
|
| 802 |
+
00:16:45,000 --> 00:16:47,000
|
| 803 |
+
Basically, that's it.
|
| 804 |
+
|
| 805 |
+
202
|
| 806 |
+
00:16:48,000 --> 00:16:54,000
|
| 807 |
+
Let's make sure that our previous web server and previous spring boot application is stopped and let's
|
| 808 |
+
|
| 809 |
+
203
|
| 810 |
+
00:16:54,000 --> 00:16:56,000
|
| 811 |
+
run this one.
|
| 812 |
+
|
| 813 |
+
204
|
| 814 |
+
00:17:00,000 --> 00:17:08,000
|
| 815 |
+
Once application is started, I open the web browser and when I hit the root resource, I see the content
|
| 816 |
+
|
| 817 |
+
205
|
| 818 |
+
00:17:08,000 --> 00:17:15,000
|
| 819 |
+
of my home page that proves that request was forwarded to the home JSP page.
|
| 820 |
+
|
| 821 |
+
206
|
| 822 |
+
00:17:15,000 --> 00:17:22,000
|
| 823 |
+
In case I tried to reach non-existent resource, you can see that I am redirected to the error page.
|
| 824 |
+
|
| 825 |
+
207
|
| 826 |
+
00:17:22,000 --> 00:17:30,000
|
| 827 |
+
This proves that default error handler that is present in spring boot resolves error view automatically.
|
| 828 |
+
|
| 829 |
+
208
|
| 830 |
+
00:17:31,000 --> 00:17:35,000
|
| 831 |
+
Congratulations with your first spring boot application.
|
| 832 |
+
|
| 833 |
+
209
|
| 834 |
+
00:17:36,000 --> 00:17:42,000
|
| 835 |
+
This is just a beginning and we still have a lot of things to learn, but we already did significant
|
| 836 |
+
|
| 837 |
+
210
|
| 838 |
+
00:17:42,000 --> 00:17:43,000
|
| 839 |
+
progress.
|
| 840 |
+
|
| 841 |
+
211
|
| 842 |
+
00:17:43,000 --> 00:17:47,000
|
| 843 |
+
Let's recap what we have learned in the lesson.
|
| 844 |
+
|
| 845 |
+
212
|
| 846 |
+
00:17:48,000 --> 00:17:52,000
|
| 847 |
+
Today we learned what spring initializer tool is and how to use it.
|
| 848 |
+
|
| 849 |
+
213
|
| 850 |
+
00:17:53,000 --> 00:18:00,000
|
| 851 |
+
We generated our first spring boot project with the help of the spring initializer tool and directly
|
| 852 |
+
|
| 853 |
+
214
|
| 854 |
+
00:18:00,000 --> 00:18:06,000
|
| 855 |
+
from the Eclipse IDE with the help of Spring Tools extension that we installed during the lesson.
|
| 856 |
+
|
| 857 |
+
215
|
| 858 |
+
00:18:07,000 --> 00:18:15,000
|
| 859 |
+
We created simple MVC controller in our first spring boot application and we saw how all this works
|
| 860 |
+
|
| 861 |
+
216
|
| 862 |
+
00:18:15,000 --> 00:18:21,000
|
| 863 |
+
in practice because we reviewed the source code and run our spring boot application.
|
| 864 |
+
|
| 865 |
+
217
|
| 866 |
+
00:18:22,000 --> 00:18:24,000
|
| 867 |
+
That's all for this lesson.
|
| 868 |
+
|
| 869 |
+
218
|
| 870 |
+
00:18:24,000 --> 00:18:26,000
|
| 871 |
+
Thanks a lot for your attention.
|
| 872 |
+
|
| 873 |
+
219
|
| 874 |
+
00:18:26,000 --> 00:18:29,000
|
| 875 |
+
Have a great day and see you in the next lesson.
|
| 876 |
+
|
92 - Spring Boot/003 Source-code-of-examples-commit-with-changes-.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/AndriiPiatakha/java-learnit-spring-boot/commit/4b8bea15fe2262ce27a63fc8a0c9059549e39c4c
|
92 - Spring Boot/003 Spring Boot Starters_en.srt
ADDED
|
@@ -0,0 +1,1612 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:05,000 --> 00:00:06,000
|
| 3 |
+
Hello team.
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:06,000 --> 00:00:10,000
|
| 7 |
+
In this video lesson, we are going to learn more about spring boot starters.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:11,000 --> 00:00:15,000
|
| 11 |
+
Today we are going to have mixed lesson, some theory and practical examples.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:15,000 --> 00:00:18,000
|
| 15 |
+
In order you can understand the topic.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:18,000 --> 00:00:24,000
|
| 19 |
+
We'll start the lesson from learning and understanding what starters are and why do we need them.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:24,000 --> 00:00:31,000
|
| 23 |
+
I will explain benefits and advantages that we as developers expect to get by using them.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:31,000 --> 00:00:38,000
|
| 27 |
+
We'll review the list of starters that you potentially may use in your spring boot applications.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:38,000 --> 00:00:45,000
|
| 31 |
+
And after learning some theory about starters, we'll jump to practical exercises and review real life
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:45,000 --> 00:00:46,000
|
| 35 |
+
examples.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:47,000 --> 00:00:52,000
|
| 39 |
+
I'm going to show you how you can add Spring Boot starter into your application.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:52,000 --> 00:00:56,000
|
| 43 |
+
We'll review web starter and create Rest API.
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:57,000 --> 00:00:59,000
|
| 47 |
+
I'm going to show you test starter.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:59,000 --> 00:01:06,000
|
| 51 |
+
We'll create few tests and we will also review data starter for the GPA.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:01:06,000 --> 00:01:12,000
|
| 55 |
+
I will show you how built in support of H2 database is configured in Spring boot.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:01:12,000 --> 00:01:18,000
|
| 59 |
+
And then I will also show you how to configure data source for MySQL database.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:01:18,000 --> 00:01:21,000
|
| 63 |
+
And at the end of the lesson we'll learn security starter.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:01:22,000 --> 00:01:23,000
|
| 67 |
+
Let's start our lesson.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:01:24,000 --> 00:01:27,000
|
| 71 |
+
Let's first learn the definition.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:01:27,000 --> 00:01:30,000
|
| 75 |
+
What are spring boot starters?
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:01:30,000 --> 00:01:31,000
|
| 79 |
+
I will explain you what.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:01:31,000 --> 00:01:35,000
|
| 83 |
+
Spring boot starters is with simple real life scenario.
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:01:36,000 --> 00:01:42,000
|
| 87 |
+
Imagine that you need to start development of rest service instead of adding dependencies of spring
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:01:42,000 --> 00:01:50,000
|
| 91 |
+
context, Spring MVC, Tomcat, Jackson select proper versions and check compatibility.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:01:50,000 --> 00:01:57,000
|
| 95 |
+
Why don't you just add one dependency that is called web starter and spring wood will do the rest.
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:01:57,000 --> 00:02:00,000
|
| 99 |
+
This should be much easier and great.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:02:00,000 --> 00:02:09,000
|
| 103 |
+
So we can say that in the context of spring boot starters are set of opinionated dependencies, dependencies,
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:02:09,000 --> 00:02:18,000
|
| 107 |
+
descriptors that provide a convenient way to add commonly used frameworks, libraries and features to
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:02:18,000 --> 00:02:20,000
|
| 111 |
+
your spring boot application.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:02:20,000 --> 00:02:30,000
|
| 115 |
+
They help simplify the configuration and setup process by providing predefined dependencies and configurations,
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:02:30,000 --> 00:02:37,000
|
| 119 |
+
allowing you to focus more on developing your application logic rather than managing dependencies.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:02:37,000 --> 00:02:45,000
|
| 123 |
+
Spring boot starters follows the principle of convention over configuration, providing sensible defaults
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:02:45,000 --> 00:02:49,000
|
| 127 |
+
and reducing the need for manual configuration.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:02:49,000 --> 00:02:57,000
|
| 131 |
+
Each starter is focused on a specific aspect of application development, such as web development,
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:02:57,000 --> 00:03:02,000
|
| 135 |
+
data, access, security, messaging, testing, etcetera.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:03:02,000 --> 00:03:10,000
|
| 139 |
+
By including a starter dependency in your spring boot project, you automatically bring in all the necessary
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:03:10,000 --> 00:03:16,000
|
| 143 |
+
dependencies and configurations required for that specific feature or functionality.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:03:16,000 --> 00:03:24,000
|
| 147 |
+
For example, including the Spring Boot starter Web starter will automatically configure the web related
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:03:24,000 --> 00:03:31,000
|
| 151 |
+
dependencies such as Embedded Tomcat Server, Spring MVC and other related components.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:03:31,000 --> 00:03:39,000
|
| 155 |
+
Starters are designed to work together seamlessly and you can combine multiple starters in your project
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:03:39,000 --> 00:03:41,000
|
| 159 |
+
to incorporate various features.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:03:41,000 --> 00:03:50,000
|
| 163 |
+
They help promote modularization and maintain a consistent and standardized approach to building spring
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:03:50,000 --> 00:03:52,000
|
| 167 |
+
boot applications.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:03:52,000 --> 00:03:59,000
|
| 171 |
+
Starters not only simplifies the initial project setup, but also provides ongoing maintenance benefits
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:03:59,000 --> 00:04:04,000
|
| 175 |
+
when new versions of libraries or frameworks are released.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:04:04,000 --> 00:04:11,000
|
| 179 |
+
The Spring Boot team ensures that the starters are up to date and compatible, making it easier to keep
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:04:11,000 --> 00:04:13,000
|
| 183 |
+
your dependencies up to date.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:04:14,000 --> 00:04:21,000
|
| 187 |
+
So spring boot starters provide a convenient and efficient way to bootstrap your spring boot projects
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:04:21,000 --> 00:04:28,000
|
| 191 |
+
by reducing the complexity of dependency management and configuration, enabling you to quickly build
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:04:28,000 --> 00:04:32,000
|
| 195 |
+
applications with the desired features and functionalities.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:04:33,000 --> 00:04:38,000
|
| 199 |
+
Now it is time for us to understand why do we need spring boot starters?
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:04:39,000 --> 00:04:40,000
|
| 203 |
+
Efficiently?
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:04:40,000 --> 00:04:47,000
|
| 207 |
+
Managing dependencies is crucial in complex projects, and manual management can be suboptimal as it
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:04:47,000 --> 00:04:54,000
|
| 211 |
+
consumes valuable time as it could be spent on other essential project aspects.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:04:54,000 --> 00:05:00,000
|
| 215 |
+
I believe if you already watch this lesson of the course, then you are not completely beginner in Java
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:05:00,000 --> 00:05:01,000
|
| 219 |
+
development.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:05:01,000 --> 00:05:09,000
|
| 223 |
+
Thus you had cases in your life when you specified dependencies that are not comparable because of different
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:05:09,000 --> 00:05:17,000
|
| 227 |
+
versions or you forget to specify some dependency and Java applications throws class not found exception
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:05:17,000 --> 00:05:18,000
|
| 231 |
+
during the runtime.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:05:19,000 --> 00:05:25,000
|
| 235 |
+
With spring boot starters, you reduce chances of doing mistake during the dependency management.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:05:25,000 --> 00:05:30,000
|
| 239 |
+
Spring boot starters were specifically developed to tackle this issue.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:05:30,000 --> 00:05:36,000
|
| 243 |
+
Let's summarize advantages that we expect to get by using spring boot starters.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:05:36,000 --> 00:05:42,000
|
| 247 |
+
Spring boot starters are designed to simplify the process of setting up and configuring spring boot
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:05:42,000 --> 00:05:43,000
|
| 251 |
+
applications.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:05:43,000 --> 00:05:50,000
|
| 255 |
+
Here are a few reasons why we need spring boot starters and what advantages we get when we use spring
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:05:50,000 --> 00:05:51,000
|
| 259 |
+
boot starters.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:05:51,000 --> 00:05:59,000
|
| 263 |
+
The first one Convenience starters provide a convenient way to add commonly used frameworks, libraries
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:05:59,000 --> 00:06:03,000
|
| 267 |
+
and features to your spring boot application.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:06:03,000 --> 00:06:10,000
|
| 271 |
+
They package together all necessary dependencies, configurations and auto configurations related to
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:06:10,000 --> 00:06:13,000
|
| 275 |
+
a specific functionality or feature.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:06:13,000 --> 00:06:20,000
|
| 279 |
+
This saves you from manually searching for and adding individual dependencies, reducing the setup time
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:06:20,000 --> 00:06:22,000
|
| 283 |
+
and complexity.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:06:22,000 --> 00:06:30,000
|
| 287 |
+
Opinionated configuration Spring boot starters Follow an opinionated approach to configuration, providing
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:06:30,000 --> 00:06:35,000
|
| 291 |
+
sensible defaults and reducing the need for extensive manual configuration.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:06:35,000 --> 00:06:42,000
|
| 295 |
+
They encapsulate best practices and predefined configurations for specific use cases, allowing you
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:06:42,000 --> 00:06:48,000
|
| 299 |
+
to get started quickly without spending time on boilerplate configuration.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:06:48,000 --> 00:06:54,000
|
| 303 |
+
Modularization Starters Promote modularization in your application.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:06:54,000 --> 00:07:02,000
|
| 307 |
+
By using starters, you can easily include all the dependencies and features that your application requires.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:07:02,000 --> 00:07:09,000
|
| 311 |
+
This helps keep the application lightweight, improves maintainability and reduces the risk of including
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:07:09,000 --> 00:07:11,000
|
| 315 |
+
unnecessary dependencies.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:07:12,000 --> 00:07:14,000
|
| 319 |
+
Compatibility and version management.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:07:15,000 --> 00:07:21,000
|
| 323 |
+
Starters are designed to work together seamlessly ensuring compatibility between different dependencies.
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:07:22,000 --> 00:07:30,000
|
| 327 |
+
Rapid development With starters, you can focus more on writing, application logic and implementing
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:07:30,000 --> 00:07:36,000
|
| 331 |
+
business requirements rather than spending time on dependency management and configuration.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:07:37,000 --> 00:07:44,000
|
| 335 |
+
They provide a streamlined development experience by abstracting away the complexities of dependency
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:07:44,000 --> 00:07:44,000
|
| 339 |
+
management.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:07:45,000 --> 00:07:47,000
|
| 343 |
+
Community support.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:07:47,000 --> 00:07:51,000
|
| 347 |
+
Spring boot starters have a great community and ecosystem around them.
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:07:52,000 --> 00:08:00,000
|
| 351 |
+
You can find extensive documentation, tutorials and resources related to each starter as well as commonly
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:08:00,000 --> 00:08:05,000
|
| 355 |
+
support through forums, blogs and stack overflow.
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:08:05,000 --> 00:08:12,000
|
| 359 |
+
This makes it easier to find help and guidance when working with specific functionalities or features.
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:08:12,000 --> 00:08:17,000
|
| 363 |
+
Probably you might be wondering which spring boot starters you can use.
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:08:17,000 --> 00:08:20,000
|
| 367 |
+
There are more than 30 spring boot starters.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:08:20,000 --> 00:08:25,000
|
| 371 |
+
Let me present you the most common and popular ones in my opinion.
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:08:26,000 --> 00:08:27,000
|
| 375 |
+
Starter web.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:08:28,000 --> 00:08:31,000
|
| 379 |
+
Starter for building web applications using spring MVC.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:08:33,000 --> 00:08:34,000
|
| 383 |
+
Starter data GPA.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:08:35,000 --> 00:08:40,000
|
| 387 |
+
This starter is for using spring data JPA for database access.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:08:40,000 --> 00:08:42,000
|
| 391 |
+
Start the security.
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:08:42,000 --> 00:08:48,000
|
| 395 |
+
Obviously, this one for adding spring security to secure your application.
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:08:48,000 --> 00:08:50,000
|
| 399 |
+
Starter test.
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:08:50,000 --> 00:08:57,000
|
| 403 |
+
Based on the name, you can guess that this one is for writing unit tests and integration tests for
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:08:57,000 --> 00:09:00,000
|
| 407 |
+
your spring boot application starter seam.
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:09:02,000 --> 00:09:08,000
|
| 411 |
+
This starter is for using the seam lift templating engine for server side rendering.
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:09:08,000 --> 00:09:15,000
|
| 415 |
+
If you don't know, seam leave is a modern server side Java template engine that is commonly used in
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:09:15,000 --> 00:09:20,000
|
| 419 |
+
web applications, especially in conjunction with Spring Framework and Spring Boot.
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:09:20,000 --> 00:09:28,000
|
| 423 |
+
It aims to bring natural templating capabilities to HTML by providing a seamless integration with Java
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:09:28,000 --> 00:09:29,000
|
| 427 |
+
ecosystem.
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:09:29,000 --> 00:09:31,000
|
| 431 |
+
Starter actuator.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:09:32,000 --> 00:09:37,000
|
| 435 |
+
This starter for monitoring and managing your application in production.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:09:38,000 --> 00:09:41,000
|
| 439 |
+
We're going to have a separate lesson about actuator to.
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:09:42,000 --> 00:09:44,000
|
| 443 |
+
Starter Amqp.
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:09:45,000 --> 00:09:52,000
|
| 447 |
+
This starter for using spring advanced message queuing protocol for messaging.
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:09:53,000 --> 00:09:57,000
|
| 451 |
+
Startup data MongoDB startup for using spring data.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:09:57,000 --> 00:10:01,000
|
| 455 |
+
MongoDB for MongoDB database access starter login.
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:10:02,000 --> 00:10:12,000
|
| 459 |
+
This one is for login using a server and Logback libraries Starter validation for using bean validation
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:10:12,000 --> 00:10:21,000
|
| 463 |
+
API Starter cache for using spring's caching support Starter mail for Send an email using Javamail.
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:10:22,000 --> 00:10:28,000
|
| 467 |
+
The rest of the popular starters and their description you can find on the slide.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:10:28,000 --> 00:10:33,000
|
| 471 |
+
But in reality, there are even more spring boot starters.
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:10:33,000 --> 00:10:38,000
|
| 475 |
+
Just take a look at this repository with the source code of spring boot starters.
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:10:39,000 --> 00:10:42,000
|
| 479 |
+
I'm sure you will be able to find the ones that you need.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:10:43,000 --> 00:10:46,000
|
| 483 |
+
Important thing is that you can create custom spring boot starter.
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:10:46,000 --> 00:10:51,000
|
| 487 |
+
And as I already said, spring community is huge.
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:10:51,000 --> 00:10:57,000
|
| 491 |
+
And before developing your own spring boot starter, just check whether such spring boot starter already
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:10:57,000 --> 00:11:00,000
|
| 495 |
+
exists in the attachments to the lesson.
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:11:00,000 --> 00:11:02,000
|
| 499 |
+
I will leave a link to the GitHub.
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:11:02,000 --> 00:11:09,000
|
| 503 |
+
The links that I present right now on the screen here you can find a list of spring boot starters and
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:11:09,000 --> 00:11:14,000
|
| 507 |
+
also a list of the custom spring boot starters created by the community.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:11:15,000 --> 00:11:19,000
|
| 511 |
+
So we learned a lot about spring boot starters.
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:11:19,000 --> 00:11:21,000
|
| 515 |
+
I believe that now you understand.
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:11:21,000 --> 00:11:22,000
|
| 519 |
+
What are they?
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:11:22,000 --> 00:11:26,000
|
| 523 |
+
The only thing that is left is to learn how to use them.
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:11:26,000 --> 00:11:31,000
|
| 527 |
+
Let me start the screen sharing and review practical examples with you.
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:11:31,000 --> 00:11:38,000
|
| 531 |
+
The first and probably the most logical question from you is how to add starter into your spring boot
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:11:38,000 --> 00:11:38,000
|
| 535 |
+
project.
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:11:39,000 --> 00:11:40,000
|
| 539 |
+
Everything is simple.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:11:41,000 --> 00:11:47,000
|
| 543 |
+
You just need to add dependency into your form XML and that's it.
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:11:47,000 --> 00:11:54,000
|
| 547 |
+
You can find the required dependency in the open repositories like Maven Repository, for example.
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:11:54,000 --> 00:11:58,000
|
| 551 |
+
The group ID would be org spring framework boot.
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:11:59,000 --> 00:12:06,000
|
| 555 |
+
The artifact ID would usually follow the pattern spring boot starter followed by the name of functionality
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:12:06,000 --> 00:12:08,000
|
| 559 |
+
or feature you want to include.
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:12:09,000 --> 00:12:15,000
|
| 563 |
+
Once the starter is added to your project's dependencies, Spring Boot will automatically configure
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:12:15,000 --> 00:12:20,000
|
| 567 |
+
the required components, dependencies and defaults for that specific functionality.
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:12:21,000 --> 00:12:27,000
|
| 571 |
+
In today's practical exercise, we are going to review different starters and we'll configure different
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:12:27,000 --> 00:12:29,000
|
| 575 |
+
spring features.
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:12:29,000 --> 00:12:32,000
|
| 579 |
+
Let's start with you from the web starter.
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:12:33,000 --> 00:12:35,000
|
| 583 |
+
I opened my pom.xml.
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:12:35,000 --> 00:12:42,000
|
| 587 |
+
In this file we specify all the required dependencies and MAVEN will handle the download of all the
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:12:42,000 --> 00:12:48,000
|
| 591 |
+
required dependencies, including additional transitive dependencies if required.
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:12:48,000 --> 00:12:51,000
|
| 595 |
+
Here you can see spring boot starter web.
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:12:52,000 --> 00:13:00,000
|
| 599 |
+
What features are added into my spring boot project after I added the starter support of web MVC Framework.
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:13:00,000 --> 00:13:08,000
|
| 603 |
+
Embedded Servlet Container Apache Tomcat Dispatcher Servlet configuration Auto configuration of web
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:13:08,000 --> 00:13:15,000
|
| 607 |
+
related dependencies such as HTTP message converters, error handling, static resource handling and
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:13:15,000 --> 00:13:16,000
|
| 611 |
+
session management.
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:13:17,000 --> 00:13:25,000
|
| 615 |
+
Support for restful APIs by including features like request response, conversion to JSON, XML and
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:13:25,000 --> 00:13:29,000
|
| 619 |
+
HTTP method mapping to not repeat myself.
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:13:29,000 --> 00:13:35,000
|
| 623 |
+
I will not repeat the example of the simple MVC controller because that's what we did in the previous
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:13:35,000 --> 00:13:38,000
|
| 627 |
+
lesson when we created our first spring boot project.
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:13:38,000 --> 00:13:46,000
|
| 631 |
+
You can check all the details there, but just to remind you, here we have simple home controller and
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:13:46,000 --> 00:13:47,000
|
| 635 |
+
application properties.
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:13:47,000 --> 00:13:56,000
|
| 639 |
+
I configure prefix and suffix for your resolver and create a web app folder in the main insight web
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:13:56,000 --> 00:13:57,000
|
| 643 |
+
app folder.
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:13:57,000 --> 00:14:04,000
|
| 647 |
+
Created web in folder views and put the home JSP file and error JSP file.
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:14:05,000 --> 00:14:05,000
|
| 651 |
+
Error.
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:14:05,000 --> 00:14:12,000
|
| 655 |
+
JSP view is resolved automatically because spring boot configured error handler automatically.
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:14:12,000 --> 00:14:16,000
|
| 659 |
+
That's in short what we have learned in previous lesson.
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:14:16,000 --> 00:14:22,000
|
| 663 |
+
Even in case you still have any questions, you are welcome to ask your questions below the video in
|
| 664 |
+
|
| 665 |
+
167
|
| 666 |
+
00:14:22,000 --> 00:14:25,000
|
| 667 |
+
the comments and I will be happy to answer them.
|
| 668 |
+
|
| 669 |
+
168
|
| 670 |
+
00:14:26,000 --> 00:14:33,000
|
| 671 |
+
If you are a student of my course Java from zero to first job, then you remember that we have module
|
| 672 |
+
|
| 673 |
+
169
|
| 674 |
+
00:14:33,000 --> 00:14:39,000
|
| 675 |
+
about rest architecture and I showed you how to implement rest API with spring.
|
| 676 |
+
|
| 677 |
+
170
|
| 678 |
+
00:14:40,000 --> 00:14:42,000
|
| 679 |
+
The same story in spring boot.
|
| 680 |
+
|
| 681 |
+
171
|
| 682 |
+
00:14:42,000 --> 00:14:48,000
|
| 683 |
+
So just to make it clear, spring boot is not something completely different.
|
| 684 |
+
|
| 685 |
+
172
|
| 686 |
+
00:14:48,000 --> 00:14:51,000
|
| 687 |
+
It is the same spring framework and everything.
|
| 688 |
+
|
| 689 |
+
173
|
| 690 |
+
00:14:51,000 --> 00:14:57,000
|
| 691 |
+
What we have learned in previous lessons about spring framework and about its different projects is
|
| 692 |
+
|
| 693 |
+
174
|
| 694 |
+
00:14:57,000 --> 00:15:00,000
|
| 695 |
+
absolutely applicable in spring boot.
|
| 696 |
+
|
| 697 |
+
175
|
| 698 |
+
00:15:01,000 --> 00:15:08,000
|
| 699 |
+
As you can see, we just added Spring Boot Starter Web and you can proceed with implementation of Rest
|
| 700 |
+
|
| 701 |
+
176
|
| 702 |
+
00:15:08,000 --> 00:15:11,000
|
| 703 |
+
API and how to implement Rest API.
|
| 704 |
+
|
| 705 |
+
177
|
| 706 |
+
00:15:11,000 --> 00:15:17,000
|
| 707 |
+
We learned in separate lessons and there is no need for me to repeat the lessons about Rest Architecture
|
| 708 |
+
|
| 709 |
+
178
|
| 710 |
+
00:15:17,000 --> 00:15:19,000
|
| 711 |
+
and Rest API.
|
| 712 |
+
|
| 713 |
+
179
|
| 714 |
+
00:15:19,000 --> 00:15:25,000
|
| 715 |
+
If you would like to learn more about rest then please refer to the separate module about rest architecture.
|
| 716 |
+
|
| 717 |
+
180
|
| 718 |
+
00:15:25,000 --> 00:15:32,000
|
| 719 |
+
And in this lesson I'm going to show you just a simple example of rest endpoint developed in spring
|
| 720 |
+
|
| 721 |
+
181
|
| 722 |
+
00:15:32,000 --> 00:15:33,000
|
| 723 |
+
boot application.
|
| 724 |
+
|
| 725 |
+
182
|
| 726 |
+
00:15:34,000 --> 00:15:36,000
|
| 727 |
+
I created class as it is called.
|
| 728 |
+
|
| 729 |
+
183
|
| 730 |
+
00:15:36,000 --> 00:15:37,000
|
| 731 |
+
Rest Demo Controller.
|
| 732 |
+
|
| 733 |
+
184
|
| 734 |
+
00:15:37,000 --> 00:15:39,000
|
| 735 |
+
Let me open it.
|
| 736 |
+
|
| 737 |
+
185
|
| 738 |
+
00:15:39,000 --> 00:15:46,000
|
| 739 |
+
As you can see, I marked this class with rest controller annotation from the lesson about Rest API.
|
| 740 |
+
|
| 741 |
+
186
|
| 742 |
+
00:15:46,000 --> 00:15:47,000
|
| 743 |
+
With Spring framework.
|
| 744 |
+
|
| 745 |
+
187
|
| 746 |
+
00:15:47,000 --> 00:15:54,000
|
| 747 |
+
You remember that rest controller is a combination of controller annotation with response body.
|
| 748 |
+
|
| 749 |
+
188
|
| 750 |
+
00:15:54,000 --> 00:16:01,000
|
| 751 |
+
In order to not make this example super complex, I don't use database connections here.
|
| 752 |
+
|
| 753 |
+
189
|
| 754 |
+
00:16:01,000 --> 00:16:08,000
|
| 755 |
+
I use the in-memory storage which is my array list in order to store demo entities.
|
| 756 |
+
|
| 757 |
+
190
|
| 758 |
+
00:16:08,000 --> 00:16:15,000
|
| 759 |
+
Demo entity is simple entity type with only two fields ID and label.
|
| 760 |
+
|
| 761 |
+
191
|
| 762 |
+
00:16:15,000 --> 00:16:16,000
|
| 763 |
+
That's it.
|
| 764 |
+
|
| 765 |
+
192
|
| 766 |
+
00:16:17,000 --> 00:16:26,000
|
| 767 |
+
I implemented three end points to fetch all entities, to add entity and to fetch entity by ID.
|
| 768 |
+
|
| 769 |
+
193
|
| 770 |
+
00:16:27,000 --> 00:16:35,000
|
| 771 |
+
Again, we already learned naming convention for sources in Rest API and all related annotations, including
|
| 772 |
+
|
| 773 |
+
194
|
| 774 |
+
00:16:35,000 --> 00:16:37,000
|
| 775 |
+
path variable annotation.
|
| 776 |
+
|
| 777 |
+
195
|
| 778 |
+
00:16:37,000 --> 00:16:40,000
|
| 779 |
+
That's why don't stop too much on this.
|
| 780 |
+
|
| 781 |
+
196
|
| 782 |
+
00:16:41,000 --> 00:16:45,000
|
| 783 |
+
Let's now just check and make sure that everything works as expected.
|
| 784 |
+
|
| 785 |
+
197
|
| 786 |
+
00:16:46,000 --> 00:16:49,000
|
| 787 |
+
I can open Postman and send few requests.
|
| 788 |
+
|
| 789 |
+
198
|
| 790 |
+
00:16:52,000 --> 00:17:00,000
|
| 791 |
+
When I fetch all entities, I receive two entities that I added during the initialization of the list.
|
| 792 |
+
|
| 793 |
+
199
|
| 794 |
+
00:17:00,000 --> 00:17:10,000
|
| 795 |
+
Then I send post requests and add one more entity with ID three and we can see that it is added.
|
| 796 |
+
|
| 797 |
+
200
|
| 798 |
+
00:17:11,000 --> 00:17:18,000
|
| 799 |
+
I can fetch all entities one more time and we can see that entity with ID number three is added at the
|
| 800 |
+
|
| 801 |
+
201
|
| 802 |
+
00:17:18,000 --> 00:17:19,000
|
| 803 |
+
end of the list.
|
| 804 |
+
|
| 805 |
+
202
|
| 806 |
+
00:17:20,000 --> 00:17:25,000
|
| 807 |
+
And the certain point that we created it is fetching entity by ID.
|
| 808 |
+
|
| 809 |
+
203
|
| 810 |
+
00:17:26,000 --> 00:17:29,000
|
| 811 |
+
As you can see, it also works as expected.
|
| 812 |
+
|
| 813 |
+
204
|
| 814 |
+
00:17:30,000 --> 00:17:37,000
|
| 815 |
+
So as you can see, this is how easily we can boost development of Rest API with Spring boot.
|
| 816 |
+
|
| 817 |
+
205
|
| 818 |
+
00:17:37,000 --> 00:17:44,000
|
| 819 |
+
In case you want to learn more about Rest API, I invite you to check separate section about rest API
|
| 820 |
+
|
| 821 |
+
206
|
| 822 |
+
00:17:44,000 --> 00:17:45,000
|
| 823 |
+
in this course.
|
| 824 |
+
|
| 825 |
+
207
|
| 826 |
+
00:17:45,000 --> 00:17:47,000
|
| 827 |
+
At the meantime, we continue.
|
| 828 |
+
|
| 829 |
+
208
|
| 830 |
+
00:17:48,000 --> 00:17:51,000
|
| 831 |
+
Let me show you this starter in action now.
|
| 832 |
+
|
| 833 |
+
209
|
| 834 |
+
00:17:51,000 --> 00:17:55,000
|
| 835 |
+
What dependencies do we usually need for testing?
|
| 836 |
+
|
| 837 |
+
210
|
| 838 |
+
00:17:55,000 --> 00:17:56,000
|
| 839 |
+
Spring tests.
|
| 840 |
+
|
| 841 |
+
211
|
| 842 |
+
00:17:56,000 --> 00:17:58,000
|
| 843 |
+
JUnit Hamcrest.
|
| 844 |
+
|
| 845 |
+
212
|
| 846 |
+
00:17:58,000 --> 00:17:59,000
|
| 847 |
+
Mockito.
|
| 848 |
+
|
| 849 |
+
213
|
| 850 |
+
00:17:59,000 --> 00:18:05,000
|
| 851 |
+
By the way, there is a separate module about testing for software engineers in my course Java from
|
| 852 |
+
|
| 853 |
+
214
|
| 854 |
+
00:18:05,000 --> 00:18:06,000
|
| 855 |
+
zero to first job.
|
| 856 |
+
|
| 857 |
+
215
|
| 858 |
+
00:18:06,000 --> 00:18:14,000
|
| 859 |
+
If you want to learn more, I invite you to check that module so we can use Spring boot starter to include
|
| 860 |
+
|
| 861 |
+
216
|
| 862 |
+
00:18:14,000 --> 00:18:19,000
|
| 863 |
+
all required dependencies for testing automatically in the POM XML.
|
| 864 |
+
|
| 865 |
+
217
|
| 866 |
+
00:18:19,000 --> 00:18:22,000
|
| 867 |
+
I added dependency for spring boot starter test.
|
| 868 |
+
|
| 869 |
+
218
|
| 870 |
+
00:18:23,000 --> 00:18:29,000
|
| 871 |
+
And by the way, pay attention that you don't need to specify a version of the dependency.
|
| 872 |
+
|
| 873 |
+
219
|
| 874 |
+
00:18:29,000 --> 00:18:30,000
|
| 875 |
+
Why?
|
| 876 |
+
|
| 877 |
+
220
|
| 878 |
+
00:18:30,000 --> 00:18:37,000
|
| 879 |
+
Because during the generation of Spring boot project we also generated this POM with a declaration of
|
| 880 |
+
|
| 881 |
+
221
|
| 882 |
+
00:18:37,000 --> 00:18:42,000
|
| 883 |
+
the spring boot starter parent as a parent for this project.
|
| 884 |
+
|
| 885 |
+
222
|
| 886 |
+
00:18:42,000 --> 00:18:44,000
|
| 887 |
+
And we specified version here.
|
| 888 |
+
|
| 889 |
+
223
|
| 890 |
+
00:18:45,000 --> 00:18:48,000
|
| 891 |
+
After that, spring boot will take care of versions compatible.
|
| 892 |
+
|
| 893 |
+
224
|
| 894 |
+
00:18:49,000 --> 00:18:52,000
|
| 895 |
+
So I added this starter.
|
| 896 |
+
|
| 897 |
+
225
|
| 898 |
+
00:18:52,000 --> 00:19:00,000
|
| 899 |
+
Also, pay attention that I specified scope of the dependency to test because I don't need these dependencies
|
| 900 |
+
|
| 901 |
+
226
|
| 902 |
+
00:19:00,000 --> 00:19:02,000
|
| 903 |
+
in my production ready archive.
|
| 904 |
+
|
| 905 |
+
227
|
| 906 |
+
00:19:03,000 --> 00:19:06,000
|
| 907 |
+
I just need these dependencies for the test phase.
|
| 908 |
+
|
| 909 |
+
228
|
| 910 |
+
00:19:07,000 --> 00:19:12,000
|
| 911 |
+
Let's now test the controller that we created in the previous example.
|
| 912 |
+
|
| 913 |
+
229
|
| 914 |
+
00:19:12,000 --> 00:19:14,000
|
| 915 |
+
Under Test Java folder.
|
| 916 |
+
|
| 917 |
+
230
|
| 918 |
+
00:19:14,000 --> 00:19:18,000
|
| 919 |
+
I created class that is called Demo Controller test.
|
| 920 |
+
|
| 921 |
+
231
|
| 922 |
+
00:19:19,000 --> 00:19:21,000
|
| 923 |
+
Everything is simple here.
|
| 924 |
+
|
| 925 |
+
232
|
| 926 |
+
00:19:21,000 --> 00:19:27,000
|
| 927 |
+
That is because Spring Boot provides excellent integration with five out of the box.
|
| 928 |
+
|
| 929 |
+
233
|
| 930 |
+
00:19:27,000 --> 00:19:36,000
|
| 931 |
+
JUnit five has its own built in test runner called JUnit platform, which is automatically used when
|
| 932 |
+
|
| 933 |
+
234
|
| 934 |
+
00:19:36,000 --> 00:19:39,000
|
| 935 |
+
running tests in a spring boot application.
|
| 936 |
+
|
| 937 |
+
235
|
| 938 |
+
00:19:39,000 --> 00:19:46,000
|
| 939 |
+
This means that you don't need to explicitly specify a custom runner using run with for your spring
|
| 940 |
+
|
| 941 |
+
236
|
| 942 |
+
00:19:46,000 --> 00:19:53,000
|
| 943 |
+
boot tests in spring boot test configuration and setup can be achieved using annotations like Spring
|
| 944 |
+
|
| 945 |
+
237
|
| 946 |
+
00:19:53,000 --> 00:19:58,000
|
| 947 |
+
Boot Test, Web MVC test or data test.
|
| 948 |
+
|
| 949 |
+
238
|
| 950 |
+
00:19:59,000 --> 00:20:07,000
|
| 951 |
+
These annotations, along with other specialized annotations, provide a streamlined approach to configuring
|
| 952 |
+
|
| 953 |
+
239
|
| 954 |
+
00:20:07,000 --> 00:20:10,000
|
| 955 |
+
and running tests in different contexts.
|
| 956 |
+
|
| 957 |
+
240
|
| 958 |
+
00:20:10,000 --> 00:20:15,000
|
| 959 |
+
Web database without the need for a custom test Runner.
|
| 960 |
+
|
| 961 |
+
241
|
| 962 |
+
00:20:15,000 --> 00:20:22,000
|
| 963 |
+
The Spring Boot test annotation is used to specify that a particular class or classes should be treated
|
| 964 |
+
|
| 965 |
+
242
|
| 966 |
+
00:20:22,000 --> 00:20:29,000
|
| 967 |
+
as a test class, and it triggers the setup of the spring boot testing infrastructure.
|
| 968 |
+
|
| 969 |
+
243
|
| 970 |
+
00:20:29,000 --> 00:20:37,000
|
| 971 |
+
The specified class serves as an entry point for building the context, including scanning for components,
|
| 972 |
+
|
| 973 |
+
244
|
| 974 |
+
00:20:37,000 --> 00:20:41,000
|
| 975 |
+
setting up configurations and initializing the necessary beans.
|
| 976 |
+
|
| 977 |
+
245
|
| 978 |
+
00:20:42,000 --> 00:20:50,000
|
| 979 |
+
And you can see here I used enable web MVC annotation using enable weapon can be beneficial in certain
|
| 980 |
+
|
| 981 |
+
246
|
| 982 |
+
00:20:50,000 --> 00:20:57,000
|
| 983 |
+
scenarios when you need to customize the web configuration specifically for your tests.
|
| 984 |
+
|
| 985 |
+
247
|
| 986 |
+
00:20:57,000 --> 00:21:06,000
|
| 987 |
+
By using enable web MVC, you can ensure that the complete MVC infrastructure is enabled for your tests,
|
| 988 |
+
|
| 989 |
+
248
|
| 990 |
+
00:21:06,000 --> 00:21:10,000
|
| 991 |
+
giving you access to the full range of MVC capabilities.
|
| 992 |
+
|
| 993 |
+
249
|
| 994 |
+
00:21:10,000 --> 00:21:17,000
|
| 995 |
+
In the properties, you can see that I declared web application context and mock MVC.
|
| 996 |
+
|
| 997 |
+
250
|
| 998 |
+
00:21:17,000 --> 00:21:23,000
|
| 999 |
+
Mock MVC is a special type that would allow us to test spring MVC behavior.
|
| 1000 |
+
|
| 1001 |
+
251
|
| 1002 |
+
00:21:23,000 --> 00:21:25,000
|
| 1003 |
+
Before each test.
|
| 1004 |
+
|
| 1005 |
+
252
|
| 1006 |
+
00:21:25,000 --> 00:21:27,000
|
| 1007 |
+
I will configure Mock MVC.
|
| 1008 |
+
|
| 1009 |
+
253
|
| 1010 |
+
00:21:27,000 --> 00:21:34,000
|
| 1011 |
+
I would use Mock MVC Builders and web application contexts to build mock MVC.
|
| 1012 |
+
|
| 1013 |
+
254
|
| 1014 |
+
00:21:34,000 --> 00:21:38,000
|
| 1015 |
+
What I recommend you to do is to download the source code.
|
| 1016 |
+
|
| 1017 |
+
255
|
| 1018 |
+
00:21:39,000 --> 00:21:46,000
|
| 1019 |
+
I would leave a link in attachments to the lesson and just spend some time up to 30 minutes just by
|
| 1020 |
+
|
| 1021 |
+
256
|
| 1022 |
+
00:21:46,000 --> 00:21:50,000
|
| 1023 |
+
reading the documentation and looking through the API of these types.
|
| 1024 |
+
|
| 1025 |
+
257
|
| 1026 |
+
00:21:50,000 --> 00:21:55,000
|
| 1027 |
+
For example, mock MVC Builder's class has just two methods.
|
| 1028 |
+
|
| 1029 |
+
258
|
| 1030 |
+
00:21:56,000 --> 00:22:01,000
|
| 1031 |
+
It wouldn't take too much time for reading, but will be useful for you.
|
| 1032 |
+
|
| 1033 |
+
259
|
| 1034 |
+
00:22:01,000 --> 00:22:03,000
|
| 1035 |
+
The same story with other classes.
|
| 1036 |
+
|
| 1037 |
+
260
|
| 1038 |
+
00:22:04,000 --> 00:22:08,000
|
| 1039 |
+
Taking into account scope and agenda of the lesson, I would continue.
|
| 1040 |
+
|
| 1041 |
+
261
|
| 1042 |
+
00:22:08,000 --> 00:22:15,000
|
| 1043 |
+
But even in case you have any questions, you can always leave your questions in comments below the
|
| 1044 |
+
|
| 1045 |
+
262
|
| 1046 |
+
00:22:15,000 --> 00:22:17,000
|
| 1047 |
+
video and I will be happy to answer.
|
| 1048 |
+
|
| 1049 |
+
263
|
| 1050 |
+
00:22:18,000 --> 00:22:23,000
|
| 1051 |
+
So I configured mock MVC and here is example of the test.
|
| 1052 |
+
|
| 1053 |
+
264
|
| 1054 |
+
00:22:23,000 --> 00:22:33,000
|
| 1055 |
+
The test verifies that when we send requests to the entities endpoint, we receive status of 200 and
|
| 1056 |
+
|
| 1057 |
+
265
|
| 1058 |
+
00:22:33,000 --> 00:22:41,000
|
| 1059 |
+
we receive response with expected content type, which is application JSON, and that there are two
|
| 1060 |
+
|
| 1061 |
+
266
|
| 1062 |
+
00:22:41,000 --> 00:22:43,000
|
| 1063 |
+
items in the JSON.
|
| 1064 |
+
|
| 1065 |
+
267
|
| 1066 |
+
00:22:44,000 --> 00:22:51,000
|
| 1067 |
+
Just to remind you two items, because by default, I initialize the state of the list with two items.
|
| 1068 |
+
|
| 1069 |
+
268
|
| 1070 |
+
00:22:52,000 --> 00:22:57,000
|
| 1071 |
+
Json.parse is a static method from MVC result matchers.
|
| 1072 |
+
|
| 1073 |
+
269
|
| 1074 |
+
00:22:57,000 --> 00:23:03,000
|
| 1075 |
+
I recommend you to check the documentation about these matches to the different matchers that can be
|
| 1076 |
+
|
| 1077 |
+
270
|
| 1078 |
+
00:23:03,000 --> 00:23:07,000
|
| 1079 |
+
useful for testing purposes in json.parse.
|
| 1080 |
+
|
| 1081 |
+
271
|
| 1082 |
+
00:23:07,000 --> 00:23:14,000
|
| 1083 |
+
I pass expression and matcher in the context of the Json.parse method in spring boots mock and we see
|
| 1084 |
+
|
| 1085 |
+
272
|
| 1086 |
+
00:23:14,000 --> 00:23:16,000
|
| 1087 |
+
result matches.
|
| 1088 |
+
|
| 1089 |
+
273
|
| 1090 |
+
00:23:16,000 --> 00:23:21,000
|
| 1091 |
+
The dollar sign represents the root element of the JSON document.
|
| 1092 |
+
|
| 1093 |
+
274
|
| 1094 |
+
00:23:22,000 --> 00:23:30,000
|
| 1095 |
+
When using Json.parse to perform assertions on the JSON response of a mock MVC test, the dollar sign
|
| 1096 |
+
|
| 1097 |
+
275
|
| 1098 |
+
00:23:30,000 --> 00:23:35,000
|
| 1099 |
+
is used to specify the starting point for the JSON parse expression.
|
| 1100 |
+
|
| 1101 |
+
276
|
| 1102 |
+
00:23:35,000 --> 00:23:40,000
|
| 1103 |
+
It allows you to navigate and extract values from the JSON structure.
|
| 1104 |
+
|
| 1105 |
+
277
|
| 1106 |
+
00:23:40,000 --> 00:23:49,000
|
| 1107 |
+
But in this case we just referred to the root element, namely the array of elements and confirmed that
|
| 1108 |
+
|
| 1109 |
+
278
|
| 1110 |
+
00:23:49,000 --> 00:23:51,000
|
| 1111 |
+
there are two elements.
|
| 1112 |
+
|
| 1113 |
+
279
|
| 1114 |
+
00:23:52,000 --> 00:23:58,000
|
| 1115 |
+
When I run this test, I can see that my test is passed successfully.
|
| 1116 |
+
|
| 1117 |
+
280
|
| 1118 |
+
00:23:58,000 --> 00:24:00,000
|
| 1119 |
+
So you have the source code.
|
| 1120 |
+
|
| 1121 |
+
281
|
| 1122 |
+
00:24:00,000 --> 00:24:07,000
|
| 1123 |
+
I recommend you to play with it, read documentation, and think about potentially other scenarios.
|
| 1124 |
+
|
| 1125 |
+
282
|
| 1126 |
+
00:24:07,000 --> 00:24:11,000
|
| 1127 |
+
Please let me know in case you would have any questions.
|
| 1128 |
+
|
| 1129 |
+
283
|
| 1130 |
+
00:24:11,000 --> 00:24:14,000
|
| 1131 |
+
Let's continue and check another starter.
|
| 1132 |
+
|
| 1133 |
+
284
|
| 1134 |
+
00:24:15,000 --> 00:24:19,000
|
| 1135 |
+
Also in the course we learned how to work with Spring Data JPA.
|
| 1136 |
+
|
| 1137 |
+
285
|
| 1138 |
+
00:24:20,000 --> 00:24:27,000
|
| 1139 |
+
Again, this is not a lesson about spring data JPA because I had dedicated module for that, so feel
|
| 1140 |
+
|
| 1141 |
+
286
|
| 1142 |
+
00:24:27,000 --> 00:24:30,000
|
| 1143 |
+
free to refer to those lessons.
|
| 1144 |
+
|
| 1145 |
+
287
|
| 1146 |
+
00:24:30,000 --> 00:24:38,000
|
| 1147 |
+
In this video I will just hold the demo and overview of Spring Boot Starter Data JPA because all the
|
| 1148 |
+
|
| 1149 |
+
288
|
| 1150 |
+
00:24:38,000 --> 00:24:44,000
|
| 1151 |
+
principles that we learned in lessons about spring data JPA are applied for Spring Boot to.
|
| 1152 |
+
|
| 1153 |
+
289
|
| 1154 |
+
00:24:45,000 --> 00:24:52,000
|
| 1155 |
+
So in the POM maximum I added starter data GPA and I also added H2 database.
|
| 1156 |
+
|
| 1157 |
+
290
|
| 1158 |
+
00:24:52,000 --> 00:24:59,000
|
| 1159 |
+
H2 is an in-memory database engine written in Java that provides several advantages for development
|
| 1160 |
+
|
| 1161 |
+
291
|
| 1162 |
+
00:24:59,000 --> 00:25:01,000
|
| 1163 |
+
and testing purposes.
|
| 1164 |
+
|
| 1165 |
+
292
|
| 1166 |
+
00:25:01,000 --> 00:25:08,000
|
| 1167 |
+
I used H2 database because it is lightweight and I don't want to over complicate this example.
|
| 1168 |
+
|
| 1169 |
+
293
|
| 1170 |
+
00:25:08,000 --> 00:25:16,000
|
| 1171 |
+
H2 supports an in-memory mode allowing you to create and run databases entirely in memory.
|
| 1172 |
+
|
| 1173 |
+
294
|
| 1174 |
+
00:25:16,000 --> 00:25:24,000
|
| 1175 |
+
This eliminates the need for disk input output operations, resulting in faster data access.
|
| 1176 |
+
|
| 1177 |
+
295
|
| 1178 |
+
00:25:24,000 --> 00:25:32,000
|
| 1179 |
+
Additionally, H2 can be embedded within your application, making it ideal for unit tests or scenarios
|
| 1180 |
+
|
| 1181 |
+
296
|
| 1182 |
+
00:25:32,000 --> 00:25:37,000
|
| 1183 |
+
where you don't want to set up separate database server.
|
| 1184 |
+
|
| 1185 |
+
297
|
| 1186 |
+
00:25:37,000 --> 00:25:44,000
|
| 1187 |
+
But in case there is a need in database server, again, just for the reference, there is a section
|
| 1188 |
+
|
| 1189 |
+
298
|
| 1190 |
+
00:25:44,000 --> 00:25:48,000
|
| 1191 |
+
about databases in my course Java from zero to first job.
|
| 1192 |
+
|
| 1193 |
+
299
|
| 1194 |
+
00:25:48,000 --> 00:25:56,000
|
| 1195 |
+
I am going to show you example with H2 database in order, you could see how easily you can create development
|
| 1196 |
+
|
| 1197 |
+
300
|
| 1198 |
+
00:25:56,000 --> 00:25:58,000
|
| 1199 |
+
environment and start testing.
|
| 1200 |
+
|
| 1201 |
+
301
|
| 1202 |
+
00:25:58,000 --> 00:26:03,000
|
| 1203 |
+
And then I'm going to show you another example with the MySQL integration.
|
| 1204 |
+
|
| 1205 |
+
302
|
| 1206 |
+
00:26:03,000 --> 00:26:06,000
|
| 1207 |
+
So let's start from H2 database example.
|
| 1208 |
+
|
| 1209 |
+
303
|
| 1210 |
+
00:26:06,000 --> 00:26:12,000
|
| 1211 |
+
First I added dependency and that's it really.
|
| 1212 |
+
|
| 1213 |
+
304
|
| 1214 |
+
00:26:12,000 --> 00:26:17,000
|
| 1215 |
+
Now you can use H2 database for testing or development purposes.
|
| 1216 |
+
|
| 1217 |
+
305
|
| 1218 |
+
00:26:17,000 --> 00:26:22,000
|
| 1219 |
+
Let's declare GP repository in the package repositories.
|
| 1220 |
+
|
| 1221 |
+
306
|
| 1222 |
+
00:26:22,000 --> 00:26:27,000
|
| 1223 |
+
You can see that I created class that is called Demo Entity Repository.
|
| 1224 |
+
|
| 1225 |
+
307
|
| 1226 |
+
00:26:27,000 --> 00:26:34,000
|
| 1227 |
+
We already learned the concept of repositories in the spring data module of the course, so I wouldn't
|
| 1228 |
+
|
| 1229 |
+
308
|
| 1230 |
+
00:26:34,000 --> 00:26:37,000
|
| 1231 |
+
stop too much on this repeating myself.
|
| 1232 |
+
|
| 1233 |
+
309
|
| 1234 |
+
00:26:38,000 --> 00:26:45,000
|
| 1235 |
+
I specified that this repository is for demo entity type that we created and primary key has integer
|
| 1236 |
+
|
| 1237 |
+
310
|
| 1238 |
+
00:26:45,000 --> 00:26:45,000
|
| 1239 |
+
type.
|
| 1240 |
+
|
| 1241 |
+
311
|
| 1242 |
+
00:26:46,000 --> 00:26:50,000
|
| 1243 |
+
I also introduced some changes in the entity itself.
|
| 1244 |
+
|
| 1245 |
+
312
|
| 1246 |
+
00:26:50,000 --> 00:26:58,000
|
| 1247 |
+
I added entity annotation and specified ID because each managed entity should have a field for ID.
|
| 1248 |
+
|
| 1249 |
+
313
|
| 1250 |
+
00:26:59,000 --> 00:27:00,000
|
| 1251 |
+
Basically.
|
| 1252 |
+
|
| 1253 |
+
314
|
| 1254 |
+
00:27:00,000 --> 00:27:00,000
|
| 1255 |
+
That's it.
|
| 1256 |
+
|
| 1257 |
+
315
|
| 1258 |
+
00:27:01,000 --> 00:27:03,000
|
| 1259 |
+
Let's test our repository.
|
| 1260 |
+
|
| 1261 |
+
316
|
| 1262 |
+
00:27:03,000 --> 00:27:09,000
|
| 1263 |
+
I created separate test in the repositories package that is called demo Entity Repository test.
|
| 1264 |
+
|
| 1265 |
+
317
|
| 1266 |
+
00:27:09,000 --> 00:27:11,000
|
| 1267 |
+
Nothing special here.
|
| 1268 |
+
|
| 1269 |
+
318
|
| 1270 |
+
00:27:11,000 --> 00:27:18,000
|
| 1271 |
+
I injected been of my repository that is under the test and I have one test case just for the sake of
|
| 1272 |
+
|
| 1273 |
+
319
|
| 1274 |
+
00:27:18,000 --> 00:27:19,000
|
| 1275 |
+
example.
|
| 1276 |
+
|
| 1277 |
+
320
|
| 1278 |
+
00:27:20,000 --> 00:27:26,000
|
| 1279 |
+
I created demo entity object and as you can see, I use my repository to save it.
|
| 1280 |
+
|
| 1281 |
+
321
|
| 1282 |
+
00:27:26,000 --> 00:27:35,000
|
| 1283 |
+
Then I use repository to extract the entity that was just saved by ID and in assertion part.
|
| 1284 |
+
|
| 1285 |
+
322
|
| 1286 |
+
00:27:35,000 --> 00:27:42,000
|
| 1287 |
+
I just want to be sure that founded entity is not null and that label of the entity that I found is
|
| 1288 |
+
|
| 1289 |
+
323
|
| 1290 |
+
00:27:42,000 --> 00:27:46,000
|
| 1291 |
+
the same as the label of entity that I saved.
|
| 1292 |
+
|
| 1293 |
+
324
|
| 1294 |
+
00:27:46,000 --> 00:27:54,000
|
| 1295 |
+
No need to test the quality of IDs because I used this ID to extract the entity from the database.
|
| 1296 |
+
|
| 1297 |
+
325
|
| 1298 |
+
00:27:55,000 --> 00:27:56,000
|
| 1299 |
+
Let me run the test.
|
| 1300 |
+
|
| 1301 |
+
326
|
| 1302 |
+
00:28:02,000 --> 00:28:05,000
|
| 1303 |
+
And you can see that it is passed as expected.
|
| 1304 |
+
|
| 1305 |
+
327
|
| 1306 |
+
00:28:05,000 --> 00:28:13,000
|
| 1307 |
+
As you saw, we didn't specify user username or password database URL, literally nothing.
|
| 1308 |
+
|
| 1309 |
+
328
|
| 1310 |
+
00:28:14,000 --> 00:28:19,000
|
| 1311 |
+
That is because springboot has out of the box support of H2O database.
|
| 1312 |
+
|
| 1313 |
+
329
|
| 1314 |
+
00:28:20,000 --> 00:28:25,000
|
| 1315 |
+
But what to do in case you need to integrate with other database.
|
| 1316 |
+
|
| 1317 |
+
330
|
| 1318 |
+
00:28:25,000 --> 00:28:26,000
|
| 1319 |
+
You can do it easily.
|
| 1320 |
+
|
| 1321 |
+
331
|
| 1322 |
+
00:28:26,000 --> 00:28:29,000
|
| 1323 |
+
Let me show you the steps.
|
| 1324 |
+
|
| 1325 |
+
332
|
| 1326 |
+
00:28:29,000 --> 00:28:35,000
|
| 1327 |
+
First of all, you need to add the required connector driver into the classpath.
|
| 1328 |
+
|
| 1329 |
+
333
|
| 1330 |
+
00:28:35,000 --> 00:28:38,000
|
| 1331 |
+
In our case I would comment now.
|
| 1332 |
+
|
| 1333 |
+
334
|
| 1334 |
+
00:28:38,000 --> 00:28:40,000
|
| 1335 |
+
Dependency of H2O database.
|
| 1336 |
+
|
| 1337 |
+
335
|
| 1338 |
+
00:28:40,000 --> 00:28:47,000
|
| 1339 |
+
You know, the spring boot wouldn't configure it automatically and I would uncomment my SQL dependency.
|
| 1340 |
+
|
| 1341 |
+
336
|
| 1342 |
+
00:28:48,000 --> 00:28:55,000
|
| 1343 |
+
Then I need to configure data source and you already know that all configurations for Spring boot should
|
| 1344 |
+
|
| 1345 |
+
337
|
| 1346 |
+
00:28:55,000 --> 00:28:58,000
|
| 1347 |
+
be placed in the application properties file.
|
| 1348 |
+
|
| 1349 |
+
338
|
| 1350 |
+
00:28:58,000 --> 00:29:02,000
|
| 1351 |
+
Here you can find configurations for the MySQL database.
|
| 1352 |
+
|
| 1353 |
+
339
|
| 1354 |
+
00:29:03,000 --> 00:29:07,000
|
| 1355 |
+
It is just a URL to the database that I created before this lesson.
|
| 1356 |
+
|
| 1357 |
+
340
|
| 1358 |
+
00:29:08,000 --> 00:29:10,000
|
| 1359 |
+
Username Password.
|
| 1360 |
+
|
| 1361 |
+
341
|
| 1362 |
+
00:29:10,000 --> 00:29:14,000
|
| 1363 |
+
Driver Class Name and Auto Generation Strategy.
|
| 1364 |
+
|
| 1365 |
+
342
|
| 1366 |
+
00:29:14,000 --> 00:29:22,000
|
| 1367 |
+
Update strategy means to update the tables that already were created and it will create tables in case
|
| 1368 |
+
|
| 1369 |
+
343
|
| 1370 |
+
00:29:22,000 --> 00:29:23,000
|
| 1371 |
+
it was absent.
|
| 1372 |
+
|
| 1373 |
+
344
|
| 1374 |
+
00:29:25,000 --> 00:29:28,000
|
| 1375 |
+
I also created an end point in the demo controller.
|
| 1376 |
+
|
| 1377 |
+
345
|
| 1378 |
+
00:29:29,000 --> 00:29:34,000
|
| 1379 |
+
It is endpoint that accepts JSON and saves entity to the database.
|
| 1380 |
+
|
| 1381 |
+
346
|
| 1382 |
+
00:29:35,000 --> 00:29:37,000
|
| 1383 |
+
Let me run the application.
|
| 1384 |
+
|
| 1385 |
+
347
|
| 1386 |
+
00:29:38,000 --> 00:29:43,000
|
| 1387 |
+
I open Postman and I send request to this endpoint.
|
| 1388 |
+
|
| 1389 |
+
348
|
| 1390 |
+
00:29:44,000 --> 00:29:45,000
|
| 1391 |
+
In the body.
|
| 1392 |
+
|
| 1393 |
+
349
|
| 1394 |
+
00:29:45,000 --> 00:29:49,000
|
| 1395 |
+
I send the entity that I want to save in the database.
|
| 1396 |
+
|
| 1397 |
+
350
|
| 1398 |
+
00:29:49,000 --> 00:29:50,000
|
| 1399 |
+
In response.
|
| 1400 |
+
|
| 1401 |
+
351
|
| 1402 |
+
00:29:50,000 --> 00:29:54,000
|
| 1403 |
+
I see message is that entity was saved successfully.
|
| 1404 |
+
|
| 1405 |
+
352
|
| 1406 |
+
00:29:54,000 --> 00:30:03,000
|
| 1407 |
+
Let me open now the MySQL workbench and you can see that I have a table created and entity with a three
|
| 1408 |
+
|
| 1409 |
+
353
|
| 1410 |
+
00:30:03,000 --> 00:30:05,000
|
| 1411 |
+
was created successfully.
|
| 1412 |
+
|
| 1413 |
+
354
|
| 1414 |
+
00:30:05,000 --> 00:30:06,000
|
| 1415 |
+
That's it.
|
| 1416 |
+
|
| 1417 |
+
355
|
| 1418 |
+
00:30:06,000 --> 00:30:08,000
|
| 1419 |
+
Congratulations.
|
| 1420 |
+
|
| 1421 |
+
356
|
| 1422 |
+
00:30:08,000 --> 00:30:11,000
|
| 1423 |
+
That's how easily we can integrate MySQL.
|
| 1424 |
+
|
| 1425 |
+
357
|
| 1426 |
+
00:30:11,000 --> 00:30:16,000
|
| 1427 |
+
In case you want to connect any other database, the algorithm is the same.
|
| 1428 |
+
|
| 1429 |
+
358
|
| 1430 |
+
00:30:17,000 --> 00:30:21,000
|
| 1431 |
+
Also, I wanted to show you security starter in action.
|
| 1432 |
+
|
| 1433 |
+
359
|
| 1434 |
+
00:30:21,000 --> 00:30:28,000
|
| 1435 |
+
And again, just for the reference, remember that we have separate module about spring security, where
|
| 1436 |
+
|
| 1437 |
+
360
|
| 1438 |
+
00:30:28,000 --> 00:30:35,000
|
| 1439 |
+
I covered a lot of possible configurations of spring security and we also did practical activities and
|
| 1440 |
+
|
| 1441 |
+
361
|
| 1442 |
+
00:30:35,000 --> 00:30:36,000
|
| 1443 |
+
home tasks.
|
| 1444 |
+
|
| 1445 |
+
362
|
| 1446 |
+
00:30:36,000 --> 00:30:42,000
|
| 1447 |
+
So in this video we don't have a goal to learn spring security from scratch.
|
| 1448 |
+
|
| 1449 |
+
363
|
| 1450 |
+
00:30:42,000 --> 00:30:47,000
|
| 1451 |
+
I just want to show you how you can easily enable spring security in your application.
|
| 1452 |
+
|
| 1453 |
+
364
|
| 1454 |
+
00:30:47,000 --> 00:30:54,000
|
| 1455 |
+
As you may already notice and understand, most of the required dependencies are easily imported by
|
| 1456 |
+
|
| 1457 |
+
365
|
| 1458 |
+
00:30:54,000 --> 00:30:55,000
|
| 1459 |
+
using starters.
|
| 1460 |
+
|
| 1461 |
+
366
|
| 1462 |
+
00:30:55,000 --> 00:31:00,000
|
| 1463 |
+
So the first thing that we need to do is to add security starter.
|
| 1464 |
+
|
| 1465 |
+
367
|
| 1466 |
+
00:31:00,000 --> 00:31:07,000
|
| 1467 |
+
After that, all required dependencies will be present in the classpath and you can jump to the configuration
|
| 1468 |
+
|
| 1469 |
+
368
|
| 1470 |
+
00:31:07,000 --> 00:31:08,000
|
| 1471 |
+
of security rules.
|
| 1472 |
+
|
| 1473 |
+
369
|
| 1474 |
+
00:31:09,000 --> 00:31:16,000
|
| 1475 |
+
After adding this starter, all endpoints are secured by default and in case you would run the application
|
| 1476 |
+
|
| 1477 |
+
370
|
| 1478 |
+
00:31:16,000 --> 00:31:23,000
|
| 1479 |
+
just with this starter and would try to reach out any endpoint, you are going to see 401.
|
| 1480 |
+
|
| 1481 |
+
371
|
| 1482 |
+
00:31:23,000 --> 00:31:26,000
|
| 1483 |
+
Unauthorized response status code.
|
| 1484 |
+
|
| 1485 |
+
372
|
| 1486 |
+
00:31:27,000 --> 00:31:32,000
|
| 1487 |
+
In order to avoid this, it is recommended you to configure security filter chain.
|
| 1488 |
+
|
| 1489 |
+
373
|
| 1490 |
+
00:31:33,000 --> 00:31:33,000
|
| 1491 |
+
Here.
|
| 1492 |
+
|
| 1493 |
+
374
|
| 1494 |
+
00:31:33,000 --> 00:31:36,000
|
| 1495 |
+
I have class with security configuration.
|
| 1496 |
+
|
| 1497 |
+
375
|
| 1498 |
+
00:31:36,000 --> 00:31:44,000
|
| 1499 |
+
I marked it with configuration annotation and enable web security, and I declared the bin of security
|
| 1500 |
+
|
| 1501 |
+
376
|
| 1502 |
+
00:31:44,000 --> 00:31:45,000
|
| 1503 |
+
filter chain.
|
| 1504 |
+
|
| 1505 |
+
377
|
| 1506 |
+
00:31:45,000 --> 00:31:51,000
|
| 1507 |
+
And then I configured security filter chain in order to allow access to all resources.
|
| 1508 |
+
|
| 1509 |
+
378
|
| 1510 |
+
00:31:52,000 --> 00:31:59,000
|
| 1511 |
+
But I believe that you remember that you can configure access based on roles and privileges to the different
|
| 1512 |
+
|
| 1513 |
+
379
|
| 1514 |
+
00:31:59,000 --> 00:31:59,000
|
| 1515 |
+
resources.
|
| 1516 |
+
|
| 1517 |
+
380
|
| 1518 |
+
00:32:00,000 --> 00:32:06,000
|
| 1519 |
+
So everything that you have learned in spring Security module is applied in spring boot to.
|
| 1520 |
+
|
| 1521 |
+
381
|
| 1522 |
+
00:32:07,000 --> 00:32:10,000
|
| 1523 |
+
That's all what I wanted to share with you in this lesson.
|
| 1524 |
+
|
| 1525 |
+
382
|
| 1526 |
+
00:32:10,000 --> 00:32:16,000
|
| 1527 |
+
The main thing that I want you to learn from this lesson is that in case you are familiar with different
|
| 1528 |
+
|
| 1529 |
+
383
|
| 1530 |
+
00:32:16,000 --> 00:32:23,000
|
| 1531 |
+
projects of spring framework, it takes you almost nothing to be familiar with Spring Boot, as you
|
| 1532 |
+
|
| 1533 |
+
384
|
| 1534 |
+
00:32:23,000 --> 00:32:24,000
|
| 1535 |
+
saw today.
|
| 1536 |
+
|
| 1537 |
+
385
|
| 1538 |
+
00:32:24,000 --> 00:32:30,000
|
| 1539 |
+
We worked with different starters and configured many different things using the knowledge that we already
|
| 1540 |
+
|
| 1541 |
+
386
|
| 1542 |
+
00:32:30,000 --> 00:32:32,000
|
| 1543 |
+
learned in previous lessons.
|
| 1544 |
+
|
| 1545 |
+
387
|
| 1546 |
+
00:32:32,000 --> 00:32:41,000
|
| 1547 |
+
Moreover, taking into account spring boot, automate a lot of things, more things left in the shadow
|
| 1548 |
+
|
| 1549 |
+
388
|
| 1550 |
+
00:32:41,000 --> 00:32:47,000
|
| 1551 |
+
and you can even understand what is happening on the background in order to be able to troubleshoot
|
| 1552 |
+
|
| 1553 |
+
389
|
| 1554 |
+
00:32:47,000 --> 00:32:54,000
|
| 1555 |
+
issues in case of any and search for required property name in the documentation if needed in order
|
| 1556 |
+
|
| 1557 |
+
390
|
| 1558 |
+
00:32:54,000 --> 00:32:57,000
|
| 1559 |
+
to add it in application properties.
|
| 1560 |
+
|
| 1561 |
+
391
|
| 1562 |
+
00:32:57,000 --> 00:33:01,000
|
| 1563 |
+
Let's recap now what we have learned in the lesson.
|
| 1564 |
+
|
| 1565 |
+
392
|
| 1566 |
+
00:33:02,000 --> 00:33:04,000
|
| 1567 |
+
We learned what starters in Spring Boot are.
|
| 1568 |
+
|
| 1569 |
+
393
|
| 1570 |
+
00:33:05,000 --> 00:33:11,000
|
| 1571 |
+
I hope that you understood why we need them and what advantages of spring boot starters are.
|
| 1572 |
+
|
| 1573 |
+
394
|
| 1574 |
+
00:33:11,000 --> 00:33:19,000
|
| 1575 |
+
We reviewed a list of spring boot starters that you potentially can use in your projects on real examples.
|
| 1576 |
+
|
| 1577 |
+
395
|
| 1578 |
+
00:33:19,000 --> 00:33:23,000
|
| 1579 |
+
We reviewed and learned how to add Spring boot starter.
|
| 1580 |
+
|
| 1581 |
+
396
|
| 1582 |
+
00:33:23,000 --> 00:33:29,000
|
| 1583 |
+
We learned web starter and developed our rest API in Spring boot.
|
| 1584 |
+
|
| 1585 |
+
397
|
| 1586 |
+
00:33:30,000 --> 00:33:34,000
|
| 1587 |
+
I showed you Test starter Spring data JPA starter.
|
| 1588 |
+
|
| 1589 |
+
398
|
| 1590 |
+
00:33:34,000 --> 00:33:41,000
|
| 1591 |
+
We configured H2 database for our spring boot application and we also learned how to declare a data
|
| 1592 |
+
|
| 1593 |
+
399
|
| 1594 |
+
00:33:41,000 --> 00:33:43,000
|
| 1595 |
+
source for my SQL database.
|
| 1596 |
+
|
| 1597 |
+
400
|
| 1598 |
+
00:33:43,000 --> 00:33:47,000
|
| 1599 |
+
And at the end of the lesson we learned security starter.
|
| 1600 |
+
|
| 1601 |
+
401
|
| 1602 |
+
00:33:47,000 --> 00:33:49,000
|
| 1603 |
+
That's all for this lesson.
|
| 1604 |
+
|
| 1605 |
+
402
|
| 1606 |
+
00:33:49,000 --> 00:33:51,000
|
| 1607 |
+
Thanks a lot for your attention.
|
| 1608 |
+
|
| 1609 |
+
403
|
| 1610 |
+
00:33:51,000 --> 00:33:54,000
|
| 1611 |
+
Have a great day and see you in the next lesson.
|
| 1612 |
+
|
92 - Spring Boot/003 Spring-Boot-Starters-on-Github.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/spring-projects/spring-boot/tree/main/spring-boot-project/spring-boot-starters
|
92 - Spring Boot/004 Common-Spring-Boot-Application-Properties.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html
|
92 - Spring Boot/004 Source-code-of-examples-commit-with-changes-.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/AndriiPiatakha/java-learnit-spring-boot/commit/1ca891ad59a291a71a5ba1df5ae4c91b87dc2734
|
92 - Spring Boot/004 Spring Boot Configurations & Application Properties_en.srt
ADDED
|
@@ -0,0 +1,1448 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:05,000 --> 00:00:06,000
|
| 3 |
+
Hello, Tim.
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:06,000 --> 00:00:10,000
|
| 7 |
+
By this moment in our course, we already learned what a spring boot is.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:10,000 --> 00:00:17,000
|
| 11 |
+
We learned spring boot starters, and we did practical exercises by running our spring boot application
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:17,000 --> 00:00:19,000
|
| 15 |
+
with different starters.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:19,000 --> 00:00:26,000
|
| 19 |
+
In this video, we are going to extend our understanding of spring boot configurations and application
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:26,000 --> 00:00:27,000
|
| 23 |
+
properties.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:28,000 --> 00:00:34,000
|
| 27 |
+
I know that you already watched previous lessons and you saw me configuring Spring Boot with the help
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:34,000 --> 00:00:36,000
|
| 31 |
+
of application Properties file.
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:36,000 --> 00:00:44,000
|
| 35 |
+
But in this lesson, let's go deeper and understand more about this configuration file.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:44,000 --> 00:00:51,000
|
| 39 |
+
We will start the lesson from the brief overview of what application properties are in Spring boot and
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:51,000 --> 00:00:52,000
|
| 43 |
+
why we need them.
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:52,000 --> 00:00:59,000
|
| 47 |
+
Then we'll review different use cases about precedence order of properties from different sources.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:59,000 --> 00:01:05,000
|
| 51 |
+
This is kind of advanced level, but I believe this can help you in real life.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:01:05,000 --> 00:01:10,000
|
| 55 |
+
You are going to understand how to override properties in case it would be needed.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:01:11,000 --> 00:01:17,000
|
| 59 |
+
We are going to review some default spring boot properties and least of the most common spring boot
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:01:17,000 --> 00:01:18,000
|
| 63 |
+
properties.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:01:19,000 --> 00:01:24,000
|
| 67 |
+
After we reviewed everything, what I have just mentioned, we will jump to practical examples.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:01:24,000 --> 00:01:29,000
|
| 71 |
+
I will start screen sharing and we will learn how to change web server port.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:01:29,000 --> 00:01:37,000
|
| 75 |
+
Yes, this is simple example, but it will help you to understand how to work with application properties.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:01:37,000 --> 00:01:39,000
|
| 79 |
+
File a little bit more.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:01:39,000 --> 00:01:42,000
|
| 83 |
+
Complex topic would be to configure SSL.
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:01:42,000 --> 00:01:48,000
|
| 87 |
+
TLS in the spring boot will generate Self-signed certificate.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:01:48,000 --> 00:01:50,000
|
| 91 |
+
I'm going to show you how to do this.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:01:50,000 --> 00:01:57,000
|
| 95 |
+
Also, I will teach you how to change the context path of the application and configure login level.
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:01:57,000 --> 00:02:04,000
|
| 99 |
+
And at the end of the lesson I am going to explain you when and how we can use configuration properties.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:02:04,000 --> 00:02:05,000
|
| 103 |
+
Annotation.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:02:05,000 --> 00:02:07,000
|
| 107 |
+
Let's start our lesson.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:02:08,000 --> 00:02:12,000
|
| 111 |
+
Let's start from learning more details about application properties.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:02:12,000 --> 00:02:19,000
|
| 115 |
+
It seems to be easy and straightforward at the first glance, but I bet that in this lesson you are
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:02:19,000 --> 00:02:21,000
|
| 119 |
+
going to learn something new.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:02:22,000 --> 00:02:29,000
|
| 123 |
+
Spring boot application Properties file is an essential part of configuring and customizing spring boot
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:02:29,000 --> 00:02:30,000
|
| 127 |
+
applications.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:02:30,000 --> 00:02:39,000
|
| 131 |
+
It provides a convenient way to externalize configuration settings and modify the behavior of your application
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:02:39,000 --> 00:02:42,000
|
| 135 |
+
without modifying the application code.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:02:42,000 --> 00:02:48,000
|
| 139 |
+
So basically, if you watched previous lessons, you should be aware that application properties file
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:02:48,000 --> 00:02:57,000
|
| 143 |
+
in Spring Boot is a text file that contains key value pairs used to configure various aspects of the
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:02:57,000 --> 00:02:58,000
|
| 147 |
+
application.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:02:58,000 --> 00:03:06,000
|
| 151 |
+
It follows a specific naming convention and can be written in various formats such as properties or
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:03:06,000 --> 00:03:07,000
|
| 155 |
+
YAML.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:03:08,000 --> 00:03:10,000
|
| 159 |
+
Where files should be located.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:03:10,000 --> 00:03:16,000
|
| 163 |
+
By default, spring boot looks for application properties file in the classpath root.
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:03:17,000 --> 00:03:18,000
|
| 167 |
+
See main resources.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:03:19,000 --> 00:03:28,000
|
| 171 |
+
But you can also specify a custom location using the spring config name and spring config location properties.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:03:29,000 --> 00:03:33,000
|
| 175 |
+
In spring boot, you may have multiple sources of application properties.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:03:33,000 --> 00:03:39,000
|
| 179 |
+
All configurations are merged together based on the predefined precedence order.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:03:40,000 --> 00:03:41,000
|
| 183 |
+
Why is this is needed?
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:03:42,000 --> 00:03:49,000
|
| 187 |
+
Because sometimes we don't have access to the application properties file itself or we don't want to
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:03:49,000 --> 00:03:50,000
|
| 191 |
+
adjust it.
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:03:50,000 --> 00:03:57,000
|
| 195 |
+
For example, we create deployment scripts and we want to automate deployment of our application in
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:03:57,000 --> 00:04:01,000
|
| 199 |
+
different environments and we need to override some properties.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:04:02,000 --> 00:04:05,000
|
| 203 |
+
Also, there can be security concern.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:04:05,000 --> 00:04:13,000
|
| 207 |
+
It is best practice to externalize sensitive information such as passwords or API keys from the application
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:04:13,000 --> 00:04:14,000
|
| 211 |
+
code.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:04:14,000 --> 00:04:18,000
|
| 215 |
+
Springboot supports the use of environment variables.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:04:18,000 --> 00:04:26,000
|
| 219 |
+
Command line arguments or external configuration files to provide these sensitive values.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:04:26,000 --> 00:04:34,000
|
| 223 |
+
This helps in maintaining a separation of configuration and code and improves security by supporting
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:04:34,000 --> 00:04:35,000
|
| 227 |
+
multiple sources.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:04:35,000 --> 00:04:43,000
|
| 231 |
+
Springboot provides flexibility in configuring and customizing applications based on specific requirements
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:04:43,000 --> 00:04:44,000
|
| 235 |
+
and environments.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:04:45,000 --> 00:04:52,000
|
| 239 |
+
Properties specified in files with high precedence overrides those with lower precedence.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:04:52,000 --> 00:04:57,000
|
| 243 |
+
The order of precedence from highest to lowest is the following.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:04:58,000 --> 00:05:03,000
|
| 247 |
+
The highest precedence have properties specified through command line arguments.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:05:04,000 --> 00:05:10,000
|
| 251 |
+
For example, instead of specifying server port in the application properties file, you can pass it
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:05:10,000 --> 00:05:15,000
|
| 255 |
+
as a command line argument like you can see in the example on the slide.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:05:16,000 --> 00:05:23,000
|
| 259 |
+
Not so often you will run your application manually, but your DevOps will create deployment scripts
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:05:23,000 --> 00:05:29,000
|
| 263 |
+
that supposed to run your application on different environments or on the same environments but with
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:05:29,000 --> 00:05:37,000
|
| 267 |
+
different configurations and DevOps will not extract your archive and adjust your application properties.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:05:37,000 --> 00:05:44,000
|
| 271 |
+
So property will be passed from the outside of the archive and will have higher precedence.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:05:44,000 --> 00:05:45,000
|
| 275 |
+
Is it clear?
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:05:45,000 --> 00:05:49,000
|
| 279 |
+
Can you understand now the business case when this can be helpful?
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:05:50,000 --> 00:05:57,000
|
| 283 |
+
The next properties specified using spring application JSON environment variable.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:05:57,000 --> 00:06:03,000
|
| 287 |
+
Do you remember like we created Javahome environment variable in the similar way you can create spring
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:06:03,000 --> 00:06:10,000
|
| 291 |
+
application JSON environment variable by setting the spring application JSON environment variable,
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:06:10,000 --> 00:06:16,000
|
| 295 |
+
you can provide custom configuration properties to your spring boot application without modifying the
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:06:16,000 --> 00:06:18,000
|
| 299 |
+
applications properties files.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:06:19,000 --> 00:06:26,000
|
| 303 |
+
These properties will take precedence over properties defined in other sources such as properties,
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:06:26,000 --> 00:06:28,000
|
| 307 |
+
files or system properties.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:06:28,000 --> 00:06:31,000
|
| 311 |
+
It may look like you can see on the slide.
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:06:32,000 --> 00:06:35,000
|
| 315 |
+
Properties specified in the Java system properties.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:06:36,000 --> 00:06:40,000
|
| 319 |
+
System properties can be specified in various ways, but one common method.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:06:40,000 --> 00:06:46,000
|
| 323 |
+
Is by using the D flag when running the Java application.
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:06:46,000 --> 00:06:51,000
|
| 327 |
+
On this slide you can see how you can specify system properties.
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:06:51,000 --> 00:06:53,000
|
| 331 |
+
By using the D flag.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:06:54,000 --> 00:06:58,000
|
| 335 |
+
You can set a specific system property for your spring boot application.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:06:59,000 --> 00:07:02,000
|
| 339 |
+
These properties will be available through the system.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:07:02,000 --> 00:07:03,000
|
| 343 |
+
Get property method.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:07:03,000 --> 00:07:05,000
|
| 347 |
+
In your application code.
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:07:05,000 --> 00:07:12,000
|
| 351 |
+
In the context of Spring boot, this system properties can be used to configure and customize various
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:07:12,000 --> 00:07:16,000
|
| 355 |
+
aspects of your application based on the specific requirements.
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:07:17,000 --> 00:07:21,000
|
| 359 |
+
Properties in the config directory of the current directory.
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:07:21,000 --> 00:07:23,000
|
| 363 |
+
Here is how it works.
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:07:23,000 --> 00:07:31,000
|
| 367 |
+
Create a directory named config in the current directory where you are running your spring boot application.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:07:31,000 --> 00:07:38,000
|
| 371 |
+
Inside the config directory place a properties file with the desired configuration properties.
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:07:38,000 --> 00:07:42,000
|
| 375 |
+
The file should typically have a properties or YAML extension.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:07:43,000 --> 00:07:50,000
|
| 379 |
+
Start your spring boot application by placing a properties file in the config directory.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:07:50,000 --> 00:07:55,000
|
| 383 |
+
Spring boot will automatically load and merge the properties from that file.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:07:55,000 --> 00:08:02,000
|
| 387 |
+
This allows you to provide additional or overriding configuration properties specific to the deployment,
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:08:02,000 --> 00:08:06,000
|
| 391 |
+
environment or machine where the application is running.
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:08:06,000 --> 00:08:14,000
|
| 395 |
+
The config directory serves as a externalized configuration location that is considered during the configuration
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:08:14,000 --> 00:08:16,000
|
| 399 |
+
merging process.
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:08:16,000 --> 00:08:23,000
|
| 403 |
+
It provides a way to externalize configuration files separate from the applications classpath or packaged
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:08:23,000 --> 00:08:24,000
|
| 407 |
+
jar file.
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:08:26,000 --> 00:08:28,000
|
| 411 |
+
Properties specified in the class pass route.
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:08:29,000 --> 00:08:37,000
|
| 415 |
+
For example, in SRC main resources in a standard spring boot project structure, the SRC main resources
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:08:37,000 --> 00:08:42,000
|
| 419 |
+
directory is where you would typically place your application properties files.
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:08:43,000 --> 00:08:47,000
|
| 423 |
+
Properties specified using spring config name environment variable.
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:08:48,000 --> 00:08:54,000
|
| 427 |
+
The spring config name environment variable allows you to specify the name of the configuration file
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:08:54,000 --> 00:09:00,000
|
| 431 |
+
without the file extension by setting the spring config name environment variable.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:09:00,000 --> 00:09:06,000
|
| 435 |
+
You can override the default name of the configuration file used by spring boot.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:09:07,000 --> 00:09:11,000
|
| 439 |
+
The default configuration file name is application.
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:09:11,000 --> 00:09:15,000
|
| 443 |
+
So setting spring config name to a different value.
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:09:15,000 --> 00:09:23,000
|
| 447 |
+
For example, custom config will make spring boot look for custom config properties or custom config
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:09:23,000 --> 00:09:26,000
|
| 451 |
+
yaml instead of application properties.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:09:27,000 --> 00:09:32,000
|
| 455 |
+
Properties specified using the spring config location environment variable.
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:09:33,000 --> 00:09:39,000
|
| 459 |
+
The spring config location environment variable allows you to specify the location of the configuration
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:09:39,000 --> 00:09:41,000
|
| 463 |
+
file or directory.
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:09:42,000 --> 00:09:49,000
|
| 467 |
+
By setting the spring config location environment variable, you can override the default location where
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:09:49,000 --> 00:09:52,000
|
| 471 |
+
spring boot searches for the configuration files.
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:09:53,000 --> 00:09:59,000
|
| 475 |
+
The default location is the classpath root src main resources.
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:10:00,000 --> 00:10:01,000
|
| 479 |
+
And the last but not the least.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:10:01,000 --> 00:10:07,000
|
| 483 |
+
And the configuration precedents are default properties provided by Spring Boot.
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:10:07,000 --> 00:10:10,000
|
| 487 |
+
We are going to learn what is a on the separate slide.
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:10:11,000 --> 00:10:18,000
|
| 491 |
+
The default properties provided by Spring Boot refer to the built in default configuration properties.
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:10:18,000 --> 00:10:24,000
|
| 495 |
+
That spring boot automatically applies if no explicit configuration is provided.
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:10:24,000 --> 00:10:32,000
|
| 499 |
+
These default properties are part of spring boot opinionated configuration approach and are designed
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:10:32,000 --> 00:10:38,000
|
| 503 |
+
to provide sensible and convenient defaults for common application configurations.
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:10:38,000 --> 00:10:45,000
|
| 507 |
+
Here are a few examples of default properties provided by Spring Boot Server port.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:10:45,000 --> 00:10:51,000
|
| 511 |
+
The default port on which the embedded web server listens is 8080.
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:10:52,000 --> 00:10:54,000
|
| 515 |
+
Spring application admin enabled.
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:10:54,000 --> 00:11:00,000
|
| 519 |
+
Whether to enable admin features for the application is false by default.
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:11:01,000 --> 00:11:02,000
|
| 523 |
+
Spring config name.
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:11:03,000 --> 00:11:05,000
|
| 527 |
+
This is the file name with configuration.
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:11:05,000 --> 00:11:11,000
|
| 531 |
+
By default, it is application spring task Execution Pool.
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:11:11,000 --> 00:11:12,000
|
| 535 |
+
Core size.
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:11:13,000 --> 00:11:14,000
|
| 539 |
+
Core number of threads.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:11:14,000 --> 00:11:16,000
|
| 543 |
+
The default value is eight.
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:11:17,000 --> 00:11:19,000
|
| 547 |
+
These are just few of them.
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:11:19,000 --> 00:11:23,000
|
| 551 |
+
You are going to learn more default spring boot properties soon.
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:11:23,000 --> 00:11:31,000
|
| 555 |
+
These default properties are automatically loaded and applied by spring boot unless overridden by explicit
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:11:31,000 --> 00:11:39,000
|
| 559 |
+
configuration provided through other means such as application properties, files, command line arguments
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:11:39,000 --> 00:11:41,000
|
| 563 |
+
or environment variables.
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:11:41,000 --> 00:11:48,000
|
| 567 |
+
The default properties provided by Spring Boot help streamline the development process by offering sensible
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:11:48,000 --> 00:11:55,000
|
| 571 |
+
and opinionated defaults, allowing developers to quickly bootstrap and configure their applications
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:11:55,000 --> 00:12:00,000
|
| 575 |
+
without explicitly specifying every configuration property.
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:12:01,000 --> 00:12:06,000
|
| 579 |
+
Let me start screen sharing and we'll review more interesting configurations on examples.
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:12:07,000 --> 00:12:10,000
|
| 583 |
+
Here is the page from the Spring Boot documentation.
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:12:10,000 --> 00:12:14,000
|
| 587 |
+
It is used to list common application properties.
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:12:14,000 --> 00:12:22,000
|
| 591 |
+
You can find property name description to understand what it is about and default value in case of any.
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:12:23,000 --> 00:12:29,000
|
| 595 |
+
On the left, you can find groups of properties, so you can start from searching through the group
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:12:29,000 --> 00:12:33,000
|
| 599 |
+
of properties or just use search on the web page.
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:12:33,000 --> 00:12:39,000
|
| 603 |
+
I will leave this link in attachments to the video and I recommend you to watch it.
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:12:39,000 --> 00:12:43,000
|
| 607 |
+
Just spend from 10 to 15 minutes looking through this page.
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:12:44,000 --> 00:12:45,000
|
| 611 |
+
Definitely.
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:12:45,000 --> 00:12:52,000
|
| 615 |
+
You will not be able to learn all possible properties at once, but the goal of this exercise is to
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:12:52,000 --> 00:13:00,000
|
| 619 |
+
understand on the high level which properties do we have and what group of properties we can spend hours
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:13:00,000 --> 00:13:03,000
|
| 623 |
+
during the video learning each property.
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:13:03,000 --> 00:13:10,000
|
| 627 |
+
But the truth is that you will not be able to remember them all until you start using them.
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:13:10,000 --> 00:13:16,000
|
| 631 |
+
So I really encourage you to look through these properties and be ready for development.
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:13:17,000 --> 00:13:24,000
|
| 635 |
+
In case you have any questions, please put your questions below the video and I will be happy to answer.
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:13:25,000 --> 00:13:29,000
|
| 639 |
+
And now let me switch to the eclipse workspace.
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:13:29,000 --> 00:13:34,000
|
| 643 |
+
I am going to show you a real life example of changing properties.
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:13:34,000 --> 00:13:35,000
|
| 647 |
+
Definitely.
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:13:35,000 --> 00:13:41,000
|
| 651 |
+
I don't have any plans to show you each property, but just some key sayings that will help you to work
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:13:41,000 --> 00:13:44,000
|
| 655 |
+
with other properties by analogy.
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:13:45,000 --> 00:13:47,000
|
| 659 |
+
Port number by default.
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:13:47,000 --> 00:13:53,000
|
| 663 |
+
Applications that are deployed on Tomcat web server are accessible via default.
|
| 664 |
+
|
| 665 |
+
167
|
| 666 |
+
00:13:53,000 --> 00:13:54,000
|
| 667 |
+
Port 8080.
|
| 668 |
+
|
| 669 |
+
168
|
| 670 |
+
00:13:55,000 --> 00:13:59,000
|
| 671 |
+
We can easily configure spring boot to use a different port.
|
| 672 |
+
|
| 673 |
+
169
|
| 674 |
+
00:14:00,000 --> 00:14:06,000
|
| 675 |
+
I open application properties and here I have section with examples for our today's lesson.
|
| 676 |
+
|
| 677 |
+
170
|
| 678 |
+
00:14:07,000 --> 00:14:12,000
|
| 679 |
+
I will share with you the link to the source code in attachments to the video and you will be able to
|
| 680 |
+
|
| 681 |
+
171
|
| 682 |
+
00:14:12,000 --> 00:14:17,000
|
| 683 |
+
check it if you wish and run examples on your local computer.
|
| 684 |
+
|
| 685 |
+
172
|
| 686 |
+
00:14:17,000 --> 00:14:23,000
|
| 687 |
+
In this particular case, our web server will be started at the port 8888.
|
| 688 |
+
|
| 689 |
+
173
|
| 690 |
+
00:14:24,000 --> 00:14:25,000
|
| 691 |
+
That was easy.
|
| 692 |
+
|
| 693 |
+
174
|
| 694 |
+
00:14:26,000 --> 00:14:33,000
|
| 695 |
+
And just in case you work in Eclipse, there is Autocompletion available for spring boot properties.
|
| 696 |
+
|
| 697 |
+
175
|
| 698 |
+
00:14:34,000 --> 00:14:41,000
|
| 699 |
+
Just feel free to use control and space simultaneously as usual in order to see Autocompletion suggestions
|
| 700 |
+
|
| 701 |
+
176
|
| 702 |
+
00:14:41,000 --> 00:14:42,000
|
| 703 |
+
for properties.
|
| 704 |
+
|
| 705 |
+
177
|
| 706 |
+
00:14:44,000 --> 00:14:46,000
|
| 707 |
+
SSL class configuration.
|
| 708 |
+
|
| 709 |
+
178
|
| 710 |
+
00:14:46,000 --> 00:14:52,000
|
| 711 |
+
Another important and interesting set of properties is related to SSL, TLS configuration.
|
| 712 |
+
|
| 713 |
+
179
|
| 714 |
+
00:14:53,000 --> 00:14:56,000
|
| 715 |
+
Just few words about semantics here.
|
| 716 |
+
|
| 717 |
+
180
|
| 718 |
+
00:14:56,000 --> 00:15:05,000
|
| 719 |
+
Both SSL, which stands for Secure Sockets Layer and TLS, which stands for Transport Layer Security
|
| 720 |
+
|
| 721 |
+
181
|
| 722 |
+
00:15:05,000 --> 00:15:11,000
|
| 723 |
+
are cryptographic protocols used to secure network communications.
|
| 724 |
+
|
| 725 |
+
182
|
| 726 |
+
00:15:11,000 --> 00:15:19,000
|
| 727 |
+
It is more accurate and up to date to refer to the current standard as TLS rather than SSL.
|
| 728 |
+
|
| 729 |
+
183
|
| 730 |
+
00:15:19,000 --> 00:15:28,000
|
| 731 |
+
SSL was the predecessor of TLS and is now considered insecure and deprecated due to security vulnerabilities.
|
| 732 |
+
|
| 733 |
+
184
|
| 734 |
+
00:15:29,000 --> 00:15:35,000
|
| 735 |
+
So let me review with you properties that are required for SSL, TLS configuration.
|
| 736 |
+
|
| 737 |
+
185
|
| 738 |
+
00:15:36,000 --> 00:15:43,000
|
| 739 |
+
The first one server SSL Keystore Type Pkcs12.
|
| 740 |
+
|
| 741 |
+
186
|
| 742 |
+
00:15:43,000 --> 00:15:50,000
|
| 743 |
+
This property specifies the type of keystore file used for SSL TLS configuration.
|
| 744 |
+
|
| 745 |
+
187
|
| 746 |
+
00:15:50,000 --> 00:16:00,000
|
| 747 |
+
In this case it is set to Pkcs12, which is a popular format for storing cryptographic objects such
|
| 748 |
+
|
| 749 |
+
188
|
| 750 |
+
00:16:00,000 --> 00:16:04,000
|
| 751 |
+
as private keys, certificates and certificate chains.
|
| 752 |
+
|
| 753 |
+
189
|
| 754 |
+
00:16:05,000 --> 00:16:10,000
|
| 755 |
+
The next property server SSL keystore.
|
| 756 |
+
|
| 757 |
+
190
|
| 758 |
+
00:16:10,000 --> 00:16:14,000
|
| 759 |
+
It is equal to root dot P12.
|
| 760 |
+
|
| 761 |
+
191
|
| 762 |
+
00:16:14,000 --> 00:16:20,000
|
| 763 |
+
This property specifies the path or location of the keystore file.
|
| 764 |
+
|
| 765 |
+
192
|
| 766 |
+
00:16:20,000 --> 00:16:29,000
|
| 767 |
+
The file name Root Point P12 indicates that the Keystore file is named Root P12.
|
| 768 |
+
|
| 769 |
+
193
|
| 770 |
+
00:16:29,000 --> 00:16:37,000
|
| 771 |
+
This file contains the necessary cryptographic material, including the private key and associated certificates
|
| 772 |
+
|
| 773 |
+
194
|
| 774 |
+
00:16:37,000 --> 00:16:40,000
|
| 775 |
+
used for SSL TLS encryption.
|
| 776 |
+
|
| 777 |
+
195
|
| 778 |
+
00:16:40,000 --> 00:16:46,000
|
| 779 |
+
In this particular example, I'm going to use Self-signed certificate for development purposes.
|
| 780 |
+
|
| 781 |
+
196
|
| 782 |
+
00:16:46,000 --> 00:16:47,000
|
| 783 |
+
What is it?
|
| 784 |
+
|
| 785 |
+
197
|
| 786 |
+
00:16:48,000 --> 00:16:54,000
|
| 787 |
+
A Self-signed certificate is a type of digital certificate that is signed by the entity to which it
|
| 788 |
+
|
| 789 |
+
198
|
| 790 |
+
00:16:54,000 --> 00:16:55,000
|
| 791 |
+
belongs.
|
| 792 |
+
|
| 793 |
+
199
|
| 794 |
+
00:16:56,000 --> 00:17:03,000
|
| 795 |
+
Unlike certificates issued by a trusted third party certificate authority, Self-signed certificates
|
| 796 |
+
|
| 797 |
+
200
|
| 798 |
+
00:17:03,000 --> 00:17:07,000
|
| 799 |
+
are not validated or verified by an external party.
|
| 800 |
+
|
| 801 |
+
201
|
| 802 |
+
00:17:07,000 --> 00:17:12,000
|
| 803 |
+
Instead, the entity generates and signs the certificate itself.
|
| 804 |
+
|
| 805 |
+
202
|
| 806 |
+
00:17:13,000 --> 00:17:20,000
|
| 807 |
+
You can't get trusted certificate just for an IP address and your home server.
|
| 808 |
+
|
| 809 |
+
203
|
| 810 |
+
00:17:20,000 --> 00:17:24,000
|
| 811 |
+
You should have some domain name, but for development purposes.
|
| 812 |
+
|
| 813 |
+
204
|
| 814 |
+
00:17:24,000 --> 00:17:29,000
|
| 815 |
+
Like I already said, you can use self-signed certificates.
|
| 816 |
+
|
| 817 |
+
205
|
| 818 |
+
00:17:29,000 --> 00:17:37,000
|
| 819 |
+
And taking into account we already touched this topic, let's also review how to generate key for TLS
|
| 820 |
+
|
| 821 |
+
206
|
| 822 |
+
00:17:37,000 --> 00:17:39,000
|
| 823 |
+
for Self-signed certificate.
|
| 824 |
+
|
| 825 |
+
207
|
| 826 |
+
00:17:40,000 --> 00:17:46,000
|
| 827 |
+
To generate a Pkcs 12 key using the Java Key two command line tool.
|
| 828 |
+
|
| 829 |
+
208
|
| 830 |
+
00:17:46,000 --> 00:17:49,000
|
| 831 |
+
Follow these instructions.
|
| 832 |
+
|
| 833 |
+
209
|
| 834 |
+
00:17:50,000 --> 00:17:58,000
|
| 835 |
+
Open a command prompt or terminal run the following Keytool command to generate a new keystore and key
|
| 836 |
+
|
| 837 |
+
210
|
| 838 |
+
00:17:58,000 --> 00:17:59,000
|
| 839 |
+
pair.
|
| 840 |
+
|
| 841 |
+
211
|
| 842 |
+
00:17:59,000 --> 00:18:02,000
|
| 843 |
+
You can find command on the screen.
|
| 844 |
+
|
| 845 |
+
212
|
| 846 |
+
00:18:03,000 --> 00:18:05,000
|
| 847 |
+
Explanation of the options used.
|
| 848 |
+
|
| 849 |
+
213
|
| 850 |
+
00:18:06,000 --> 00:18:09,000
|
| 851 |
+
Jan Keypair generates a new key pair.
|
| 852 |
+
|
| 853 |
+
214
|
| 854 |
+
00:18:10,000 --> 00:18:15,000
|
| 855 |
+
Alice My LHS specifies the alias for the key pair.
|
| 856 |
+
|
| 857 |
+
215
|
| 858 |
+
00:18:16,000 --> 00:18:17,000
|
| 859 |
+
Key algorithm.
|
| 860 |
+
|
| 861 |
+
216
|
| 862 |
+
00:18:17,000 --> 00:18:24,000
|
| 863 |
+
RSA specifies the algorithm to use for the key pair RSA in this case.
|
| 864 |
+
|
| 865 |
+
217
|
| 866 |
+
00:18:25,000 --> 00:18:26,000
|
| 867 |
+
He sighs.
|
| 868 |
+
|
| 869 |
+
218
|
| 870 |
+
00:18:26,000 --> 00:18:31,000
|
| 871 |
+
2048 specifies the key size in bits.
|
| 872 |
+
|
| 873 |
+
219
|
| 874 |
+
00:18:32,000 --> 00:18:33,000
|
| 875 |
+
Keystore.
|
| 876 |
+
|
| 877 |
+
220
|
| 878 |
+
00:18:33,000 --> 00:18:34,000
|
| 879 |
+
Keystore.
|
| 880 |
+
|
| 881 |
+
221
|
| 882 |
+
00:18:34,000 --> 00:18:39,000
|
| 883 |
+
P12 specifies the name of the Keystore file to be generated.
|
| 884 |
+
|
| 885 |
+
222
|
| 886 |
+
00:18:40,000 --> 00:18:43,000
|
| 887 |
+
Store type Pkcs12.
|
| 888 |
+
|
| 889 |
+
223
|
| 890 |
+
00:18:43,000 --> 00:18:49,000
|
| 891 |
+
Specifies the type of the Keystore as Pkcs12.
|
| 892 |
+
|
| 893 |
+
224
|
| 894 |
+
00:18:49,000 --> 00:18:56,000
|
| 895 |
+
Follow the prompts to enter the required information such as keystore, password, name, organization,
|
| 896 |
+
|
| 897 |
+
225
|
| 898 |
+
00:18:56,000 --> 00:18:57,000
|
| 899 |
+
key, etcetera.
|
| 900 |
+
|
| 901 |
+
226
|
| 902 |
+
00:18:57,000 --> 00:19:00,000
|
| 903 |
+
Provide the necessary details as prompted.
|
| 904 |
+
|
| 905 |
+
227
|
| 906 |
+
00:19:01,000 --> 00:19:09,000
|
| 907 |
+
Once process is complete, the Keystore P12 file will be generated containing the private key and the
|
| 908 |
+
|
| 909 |
+
228
|
| 910 |
+
00:19:09,000 --> 00:19:11,000
|
| 911 |
+
corresponding certificate.
|
| 912 |
+
|
| 913 |
+
229
|
| 914 |
+
00:19:11,000 --> 00:19:19,000
|
| 915 |
+
You now have pkcs12 keystore file containing the private key and certificate.
|
| 916 |
+
|
| 917 |
+
230
|
| 918 |
+
00:19:19,000 --> 00:19:27,000
|
| 919 |
+
This format allows you to store both the private key and the associated certificate in a single file.
|
| 920 |
+
|
| 921 |
+
231
|
| 922 |
+
00:19:27,000 --> 00:19:35,000
|
| 923 |
+
Please make sure to keep the Keystore file secure and protect it with a strong password as it contains
|
| 924 |
+
|
| 925 |
+
232
|
| 926 |
+
00:19:35,000 --> 00:19:37,000
|
| 927 |
+
sensitive information.
|
| 928 |
+
|
| 929 |
+
233
|
| 930 |
+
00:19:37,000 --> 00:19:46,000
|
| 931 |
+
So I generated the key following these instructions and put it in the keys folder under src main resources.
|
| 932 |
+
|
| 933 |
+
234
|
| 934 |
+
00:19:46,000 --> 00:19:48,000
|
| 935 |
+
Here it is.
|
| 936 |
+
|
| 937 |
+
235
|
| 938 |
+
00:19:48,000 --> 00:19:55,000
|
| 939 |
+
And in the application properties specify the path to the file using the class pass reference.
|
| 940 |
+
|
| 941 |
+
236
|
| 942 |
+
00:19:56,000 --> 00:19:59,000
|
| 943 |
+
Let's review the next properties from this list.
|
| 944 |
+
|
| 945 |
+
237
|
| 946 |
+
00:20:00,000 --> 00:20:02,000
|
| 947 |
+
Server SSL Keystore.
|
| 948 |
+
|
| 949 |
+
238
|
| 950 |
+
00:20:02,000 --> 00:20:03,000
|
| 951 |
+
Password.
|
| 952 |
+
|
| 953 |
+
239
|
| 954 |
+
00:20:04,000 --> 00:20:04,000
|
| 955 |
+
Root.
|
| 956 |
+
|
| 957 |
+
240
|
| 958 |
+
00:20:04,000 --> 00:20:05,000
|
| 959 |
+
Root.
|
| 960 |
+
|
| 961 |
+
241
|
| 962 |
+
00:20:05,000 --> 00:20:13,000
|
| 963 |
+
This property defines the password required to access and unlock the keystore file specified earlier.
|
| 964 |
+
|
| 965 |
+
242
|
| 966 |
+
00:20:13,000 --> 00:20:16,000
|
| 967 |
+
In this case, the password is set to root.
|
| 968 |
+
|
| 969 |
+
243
|
| 970 |
+
00:20:16,000 --> 00:20:17,000
|
| 971 |
+
Root.
|
| 972 |
+
|
| 973 |
+
244
|
| 974 |
+
00:20:17,000 --> 00:20:22,000
|
| 975 |
+
This is the one I used during the generation of my certificate.
|
| 976 |
+
|
| 977 |
+
245
|
| 978 |
+
00:20:23,000 --> 00:20:29,000
|
| 979 |
+
It is important to choose a strong and secure password to protect the Keystore file.
|
| 980 |
+
|
| 981 |
+
246
|
| 982 |
+
00:20:30,000 --> 00:20:33,000
|
| 983 |
+
Seven SSL key route.
|
| 984 |
+
|
| 985 |
+
247
|
| 986 |
+
00:20:34,000 --> 00:20:39,000
|
| 987 |
+
Again, this is another property that is specified on the generation stage.
|
| 988 |
+
|
| 989 |
+
248
|
| 990 |
+
00:20:40,000 --> 00:20:46,000
|
| 991 |
+
This property identifies the UN name for the key entry within the Keystore file.
|
| 992 |
+
|
| 993 |
+
249
|
| 994 |
+
00:20:46,000 --> 00:20:54,000
|
| 995 |
+
The key entry represents the specific cryptographic key pair, private key and associated public key
|
| 996 |
+
|
| 997 |
+
250
|
| 998 |
+
00:20:54,000 --> 00:20:59,000
|
| 999 |
+
that the server will use for SSL TLS connections.
|
| 1000 |
+
|
| 1001 |
+
251
|
| 1002 |
+
00:20:59,000 --> 00:21:03,000
|
| 1003 |
+
In this case, the key is set to root.
|
| 1004 |
+
|
| 1005 |
+
252
|
| 1006 |
+
00:21:04,000 --> 00:21:10,000
|
| 1007 |
+
These properties are used to configure SSL, TLS settings for a server.
|
| 1008 |
+
|
| 1009 |
+
253
|
| 1010 |
+
00:21:10,000 --> 00:21:17,000
|
| 1011 |
+
Specifically related to the Keystore file, its type password and the alias of the key entry.
|
| 1012 |
+
|
| 1013 |
+
254
|
| 1014 |
+
00:21:18,000 --> 00:21:25,000
|
| 1015 |
+
By properly configuring these properties, the server can establish secure connections using SSL, TLS
|
| 1016 |
+
|
| 1017 |
+
255
|
| 1018 |
+
00:21:25,000 --> 00:21:31,000
|
| 1019 |
+
protocols and protect the confidentiality and integrity of the transmitted data.
|
| 1020 |
+
|
| 1021 |
+
256
|
| 1022 |
+
00:21:32,000 --> 00:21:35,000
|
| 1023 |
+
I'm going to show you how it works in a minute.
|
| 1024 |
+
|
| 1025 |
+
257
|
| 1026 |
+
00:21:35,000 --> 00:21:42,000
|
| 1027 |
+
Let me just add a few more configurations and we'll run the application and we'll check all adjustments
|
| 1028 |
+
|
| 1029 |
+
258
|
| 1030 |
+
00:21:42,000 --> 00:21:43,000
|
| 1031 |
+
at once.
|
| 1032 |
+
|
| 1033 |
+
259
|
| 1034 |
+
00:21:44,000 --> 00:21:45,000
|
| 1035 |
+
Context sparse.
|
| 1036 |
+
|
| 1037 |
+
260
|
| 1038 |
+
00:21:45,000 --> 00:21:50,000
|
| 1039 |
+
Let's learn how to change context sparse by default.
|
| 1040 |
+
|
| 1041 |
+
261
|
| 1042 |
+
00:21:50,000 --> 00:21:53,000
|
| 1043 |
+
Our application is available at root.
|
| 1044 |
+
|
| 1045 |
+
262
|
| 1046 |
+
00:21:53,000 --> 00:21:56,000
|
| 1047 |
+
If you need to change it, you can do it too.
|
| 1048 |
+
|
| 1049 |
+
263
|
| 1050 |
+
00:21:57,000 --> 00:21:57,000
|
| 1051 |
+
Why?
|
| 1052 |
+
|
| 1053 |
+
264
|
| 1054 |
+
00:21:57,000 --> 00:22:00,000
|
| 1055 |
+
You may need to change context Sparse.
|
| 1056 |
+
|
| 1057 |
+
265
|
| 1058 |
+
00:22:00,000 --> 00:22:03,000
|
| 1059 |
+
There can be several reasons for that.
|
| 1060 |
+
|
| 1061 |
+
266
|
| 1062 |
+
00:22:03,000 --> 00:22:11,000
|
| 1063 |
+
For example, you have multiple applications on the same server or SEO optimization, Search engine
|
| 1064 |
+
|
| 1065 |
+
267
|
| 1066 |
+
00:22:11,000 --> 00:22:13,000
|
| 1067 |
+
optimization.
|
| 1068 |
+
|
| 1069 |
+
268
|
| 1070 |
+
00:22:13,000 --> 00:22:20,000
|
| 1071 |
+
You might want to include keywords or relevant information in the URL path to improve search engine
|
| 1072 |
+
|
| 1073 |
+
269
|
| 1074 |
+
00:22:20,000 --> 00:22:21,000
|
| 1075 |
+
rankings.
|
| 1076 |
+
|
| 1077 |
+
270
|
| 1078 |
+
00:22:22,000 --> 00:22:24,000
|
| 1079 |
+
Compliance with organization standards.
|
| 1080 |
+
|
| 1081 |
+
271
|
| 1082 |
+
00:22:25,000 --> 00:22:29,000
|
| 1083 |
+
It also can be a reason anyway, in case you need to change the context.
|
| 1084 |
+
|
| 1085 |
+
272
|
| 1086 |
+
00:22:29,000 --> 00:22:33,000
|
| 1087 |
+
Plus, you can easily do this like you can see on the screen.
|
| 1088 |
+
|
| 1089 |
+
273
|
| 1090 |
+
00:22:33,000 --> 00:22:37,000
|
| 1091 |
+
In this case, my context path would be spring boot demo.
|
| 1092 |
+
|
| 1093 |
+
274
|
| 1094 |
+
00:22:39,000 --> 00:22:42,000
|
| 1095 |
+
Configure the login levels if you want.
|
| 1096 |
+
|
| 1097 |
+
275
|
| 1098 |
+
00:22:42,000 --> 00:22:47,000
|
| 1099 |
+
You can easily configure login levels in spring boot application.
|
| 1100 |
+
|
| 1101 |
+
276
|
| 1102 |
+
00:22:47,000 --> 00:22:54,000
|
| 1103 |
+
Probably you saw many times the crazy amount of logs in our console during the execution of spring boot
|
| 1104 |
+
|
| 1105 |
+
277
|
| 1106 |
+
00:22:54,000 --> 00:22:55,000
|
| 1107 |
+
application.
|
| 1108 |
+
|
| 1109 |
+
278
|
| 1110 |
+
00:22:55,000 --> 00:23:02,000
|
| 1111 |
+
You can configure many different properties related to login and you can check them using the link I
|
| 1112 |
+
|
| 1113 |
+
279
|
| 1114 |
+
00:23:02,000 --> 00:23:03,000
|
| 1115 |
+
provided.
|
| 1116 |
+
|
| 1117 |
+
280
|
| 1118 |
+
00:23:03,000 --> 00:23:11,000
|
| 1119 |
+
I mean the link from the documentation with the list of common spring boot application properties.
|
| 1120 |
+
|
| 1121 |
+
281
|
| 1122 |
+
00:23:11,000 --> 00:23:17,000
|
| 1123 |
+
But in this particular example, let's just change lock level to warn.
|
| 1124 |
+
|
| 1125 |
+
282
|
| 1126 |
+
00:23:17,000 --> 00:23:25,000
|
| 1127 |
+
So basically right now we are supposed to see only warn and high levels like error and fatal.
|
| 1128 |
+
|
| 1129 |
+
283
|
| 1130 |
+
00:23:26,000 --> 00:23:30,000
|
| 1131 |
+
Pay attention that you may have many different loggers in your application.
|
| 1132 |
+
|
| 1133 |
+
284
|
| 1134 |
+
00:23:30,000 --> 00:23:37,000
|
| 1135 |
+
You can configure level for each of them, but for the sake of the demo, I will set warn level for
|
| 1136 |
+
|
| 1137 |
+
285
|
| 1138 |
+
00:23:37,000 --> 00:23:39,000
|
| 1139 |
+
the root logger.
|
| 1140 |
+
|
| 1141 |
+
286
|
| 1142 |
+
00:23:39,000 --> 00:23:47,000
|
| 1143 |
+
The root logger is a top level logger in the login hierarchy and it provides a default configuration
|
| 1144 |
+
|
| 1145 |
+
287
|
| 1146 |
+
00:23:47,000 --> 00:23:50,000
|
| 1147 |
+
for logging in an application.
|
| 1148 |
+
|
| 1149 |
+
288
|
| 1150 |
+
00:23:50,000 --> 00:23:58,000
|
| 1151 |
+
If no other loggers explicitly defined when will run application, you are going to see only logs from
|
| 1152 |
+
|
| 1153 |
+
289
|
| 1154 |
+
00:23:58,000 --> 00:24:00,000
|
| 1155 |
+
warn level in the console.
|
| 1156 |
+
|
| 1157 |
+
290
|
| 1158 |
+
00:24:01,000 --> 00:24:07,000
|
| 1159 |
+
All other possible configurations like for example, registering of the file with properties with the
|
| 1160 |
+
|
| 1161 |
+
291
|
| 1162 |
+
00:24:07,000 --> 00:24:14,000
|
| 1163 |
+
help of properties, source annotation error handling, using a value, annotation and everything.
|
| 1164 |
+
|
| 1165 |
+
292
|
| 1166 |
+
00:24:14,000 --> 00:24:20,000
|
| 1167 |
+
What we have learned in the Spring framework course is applicable in the same way in the spring boot.
|
| 1168 |
+
|
| 1169 |
+
293
|
| 1170 |
+
00:24:21,000 --> 00:24:23,000
|
| 1171 |
+
That's why I will not repeat myself.
|
| 1172 |
+
|
| 1173 |
+
294
|
| 1174 |
+
00:24:24,000 --> 00:24:30,000
|
| 1175 |
+
I believe that you understand how to use application properties for configuration of your spring boot
|
| 1176 |
+
|
| 1177 |
+
295
|
| 1178 |
+
00:24:30,000 --> 00:24:31,000
|
| 1179 |
+
application.
|
| 1180 |
+
|
| 1181 |
+
296
|
| 1182 |
+
00:24:31,000 --> 00:24:39,000
|
| 1183 |
+
The last and interesting things that I want to show you in this lesson is how to use configuration properties
|
| 1184 |
+
|
| 1185 |
+
297
|
| 1186 |
+
00:24:39,000 --> 00:24:40,000
|
| 1187 |
+
with beans.
|
| 1188 |
+
|
| 1189 |
+
298
|
| 1190 |
+
00:24:40,000 --> 00:24:48,000
|
| 1191 |
+
Imagine the case that you have set body component that is outside of your control and you need to bind
|
| 1192 |
+
|
| 1193 |
+
299
|
| 1194 |
+
00:24:48,000 --> 00:24:50,000
|
| 1195 |
+
your custom properties to it.
|
| 1196 |
+
|
| 1197 |
+
300
|
| 1198 |
+
00:24:51,000 --> 00:24:52,000
|
| 1199 |
+
What to do in this case?
|
| 1200 |
+
|
| 1201 |
+
301
|
| 1202 |
+
00:24:53,000 --> 00:24:59,000
|
| 1203 |
+
In this case, we can use configuration properties annotation with bin configuration.
|
| 1204 |
+
|
| 1205 |
+
302
|
| 1206 |
+
00:24:59,000 --> 00:25:07,000
|
| 1207 |
+
The configuration properties, annotation and spring boot is used to bind external configuration properties
|
| 1208 |
+
|
| 1209 |
+
303
|
| 1210 |
+
00:25:07,000 --> 00:25:08,000
|
| 1211 |
+
to a Java object.
|
| 1212 |
+
|
| 1213 |
+
304
|
| 1214 |
+
00:25:09,000 --> 00:25:12,000
|
| 1215 |
+
It allows you to map properties from various sources.
|
| 1216 |
+
|
| 1217 |
+
305
|
| 1218 |
+
00:25:12,000 --> 00:25:17,000
|
| 1219 |
+
Do you remember that we have demo entity in our project here?
|
| 1220 |
+
|
| 1221 |
+
306
|
| 1222 |
+
00:25:17,000 --> 00:25:25,000
|
| 1223 |
+
In the entities package, let's imagine that I need to bind properties to the bin of demo entity type.
|
| 1224 |
+
|
| 1225 |
+
307
|
| 1226 |
+
00:25:26,000 --> 00:25:29,000
|
| 1227 |
+
I created separate class that is called bin configuration.
|
| 1228 |
+
|
| 1229 |
+
308
|
| 1230 |
+
00:25:30,000 --> 00:25:32,000
|
| 1231 |
+
In this class I want to configure one bin.
|
| 1232 |
+
|
| 1233 |
+
309
|
| 1234 |
+
00:25:33,000 --> 00:25:37,000
|
| 1235 |
+
You can see that I use bin annotation as usual.
|
| 1236 |
+
|
| 1237 |
+
310
|
| 1238 |
+
00:25:37,000 --> 00:25:41,000
|
| 1239 |
+
And here is configuration properties annotation bin.
|
| 1240 |
+
|
| 1241 |
+
311
|
| 1242 |
+
00:25:41,000 --> 00:25:45,000
|
| 1243 |
+
I specify prefix what this prefix for.
|
| 1244 |
+
|
| 1245 |
+
312
|
| 1246 |
+
00:25:45,000 --> 00:25:48,000
|
| 1247 |
+
Let me now open application properties.
|
| 1248 |
+
|
| 1249 |
+
313
|
| 1250 |
+
00:25:48,000 --> 00:25:52,000
|
| 1251 |
+
Here you can see properties that are started from the entity verb.
|
| 1252 |
+
|
| 1253 |
+
314
|
| 1254 |
+
00:25:53,000 --> 00:25:59,000
|
| 1255 |
+
And after the point, I specified the name of the objects property.
|
| 1256 |
+
|
| 1257 |
+
315
|
| 1258 |
+
00:26:00,000 --> 00:26:01,000
|
| 1259 |
+
In entity.
|
| 1260 |
+
|
| 1261 |
+
316
|
| 1262 |
+
00:26:01,000 --> 00:26:09,000
|
| 1263 |
+
I have ID and label fields and here is a SO spring is smart enough to bind the properties with a similar
|
| 1264 |
+
|
| 1265 |
+
317
|
| 1266 |
+
00:26:09,000 --> 00:26:10,000
|
| 1267 |
+
names.
|
| 1268 |
+
|
| 1269 |
+
318
|
| 1270 |
+
00:26:10,000 --> 00:26:11,000
|
| 1271 |
+
That's it.
|
| 1272 |
+
|
| 1273 |
+
319
|
| 1274 |
+
00:26:11,000 --> 00:26:20,000
|
| 1275 |
+
In beans configuration I do nothing more, but when the bean will be created, spring will make sure
|
| 1276 |
+
|
| 1277 |
+
320
|
| 1278 |
+
00:26:20,000 --> 00:26:26,000
|
| 1279 |
+
that properties values are equal to the one provided in the application properties file.
|
| 1280 |
+
|
| 1281 |
+
321
|
| 1282 |
+
00:26:27,000 --> 00:26:34,000
|
| 1283 |
+
For the sake of the demo, I also created an endpoint in the class demo entity Properties controller.
|
| 1284 |
+
|
| 1285 |
+
322
|
| 1286 |
+
00:26:34,000 --> 00:26:41,000
|
| 1287 |
+
I will just request this resource and we are going to see the state of the demo entity Bean, namely
|
| 1288 |
+
|
| 1289 |
+
323
|
| 1290 |
+
00:26:41,000 --> 00:26:48,000
|
| 1291 |
+
its ID and label to make sure that these properties have value as it is specified in the properties
|
| 1292 |
+
|
| 1293 |
+
324
|
| 1294 |
+
00:26:48,000 --> 00:26:49,000
|
| 1295 |
+
file.
|
| 1296 |
+
|
| 1297 |
+
325
|
| 1298 |
+
00:26:50,000 --> 00:26:53,000
|
| 1299 |
+
So now we are ready to run the application.
|
| 1300 |
+
|
| 1301 |
+
326
|
| 1302 |
+
00:26:55,000 --> 00:26:56,000
|
| 1303 |
+
The server is started.
|
| 1304 |
+
|
| 1305 |
+
327
|
| 1306 |
+
00:26:57,000 --> 00:26:59,000
|
| 1307 |
+
Take a look at console output.
|
| 1308 |
+
|
| 1309 |
+
328
|
| 1310 |
+
00:27:00,000 --> 00:27:03,000
|
| 1311 |
+
You can see only worn logs.
|
| 1312 |
+
|
| 1313 |
+
329
|
| 1314 |
+
00:27:03,000 --> 00:27:07,000
|
| 1315 |
+
That is because we configured login level for root logger.
|
| 1316 |
+
|
| 1317 |
+
330
|
| 1318 |
+
00:27:08,000 --> 00:27:13,000
|
| 1319 |
+
Now let's open the browser and check all our configurations.
|
| 1320 |
+
|
| 1321 |
+
331
|
| 1322 |
+
00:27:14,000 --> 00:27:21,000
|
| 1323 |
+
The first time you open the web page using the Self-signed certificate browser will ask you whether
|
| 1324 |
+
|
| 1325 |
+
332
|
| 1326 |
+
00:27:21,000 --> 00:27:29,000
|
| 1327 |
+
you really trust the certificate because browser understands that the certificate used for TLS connection
|
| 1328 |
+
|
| 1329 |
+
333
|
| 1330 |
+
00:27:29,000 --> 00:27:32,000
|
| 1331 |
+
is not issued by trusted authority.
|
| 1332 |
+
|
| 1333 |
+
334
|
| 1334 |
+
00:27:32,000 --> 00:27:40,000
|
| 1335 |
+
You just need to expand for additional details and click this hyper reference in order to tell the browser
|
| 1336 |
+
|
| 1337 |
+
335
|
| 1338 |
+
00:27:40,000 --> 00:27:42,000
|
| 1339 |
+
that you are agreed to.
|
| 1340 |
+
|
| 1341 |
+
336
|
| 1342 |
+
00:27:42,000 --> 00:27:43,000
|
| 1343 |
+
Proceed with the connection.
|
| 1344 |
+
|
| 1345 |
+
337
|
| 1346 |
+
00:27:44,000 --> 00:27:48,000
|
| 1347 |
+
And then we can proceed to the root of our application.
|
| 1348 |
+
|
| 1349 |
+
338
|
| 1350 |
+
00:27:48,000 --> 00:27:57,000
|
| 1351 |
+
Pay attention that our application is available at the Spring Boot demo context with the port 8888.
|
| 1352 |
+
|
| 1353 |
+
339
|
| 1354 |
+
00:27:58,000 --> 00:28:02,000
|
| 1355 |
+
Also, you can see that I use HTTPS protocol for connection.
|
| 1356 |
+
|
| 1357 |
+
340
|
| 1358 |
+
00:28:02,000 --> 00:28:05,000
|
| 1359 |
+
That is because we configured TLS SSL.
|
| 1360 |
+
|
| 1361 |
+
341
|
| 1362 |
+
00:28:05,000 --> 00:28:13,000
|
| 1363 |
+
It shows that it is not protected because I use Self-signed certificate, but not the certificate from
|
| 1364 |
+
|
| 1365 |
+
342
|
| 1366 |
+
00:28:13,000 --> 00:28:14,000
|
| 1367 |
+
the trusted authority.
|
| 1368 |
+
|
| 1369 |
+
343
|
| 1370 |
+
00:28:14,000 --> 00:28:17,000
|
| 1371 |
+
But for development purposes that is fine.
|
| 1372 |
+
|
| 1373 |
+
344
|
| 1374 |
+
00:28:17,000 --> 00:28:23,000
|
| 1375 |
+
In production you are going to substitute the certificate itself, but configurations will remain the
|
| 1376 |
+
|
| 1377 |
+
345
|
| 1378 |
+
00:28:23,000 --> 00:28:24,000
|
| 1379 |
+
same.
|
| 1380 |
+
|
| 1381 |
+
346
|
| 1382 |
+
00:28:24,000 --> 00:28:31,000
|
| 1383 |
+
And now let me reach our test endpoint in order to check the state of the demo entity object.
|
| 1384 |
+
|
| 1385 |
+
347
|
| 1386 |
+
00:28:32,000 --> 00:28:41,000
|
| 1387 |
+
And here we can see that ID of our entity is 100 and label is test label as it was configured in application
|
| 1388 |
+
|
| 1389 |
+
348
|
| 1390 |
+
00:28:41,000 --> 00:28:42,000
|
| 1391 |
+
properties.
|
| 1392 |
+
|
| 1393 |
+
349
|
| 1394 |
+
00:28:43,000 --> 00:28:46,000
|
| 1395 |
+
So that's all what I wanted to share with you today.
|
| 1396 |
+
|
| 1397 |
+
350
|
| 1398 |
+
00:28:46,000 --> 00:28:50,000
|
| 1399 |
+
Let's recap what we have learned in the lesson.
|
| 1400 |
+
|
| 1401 |
+
351
|
| 1402 |
+
00:28:50,000 --> 00:28:54,000
|
| 1403 |
+
We learned more about application properties.
|
| 1404 |
+
|
| 1405 |
+
352
|
| 1406 |
+
00:28:54,000 --> 00:29:01,000
|
| 1407 |
+
Now you know the precedence order of properties and how to override properties in case this will be
|
| 1408 |
+
|
| 1409 |
+
353
|
| 1410 |
+
00:29:01,000 --> 00:29:01,000
|
| 1411 |
+
needed.
|
| 1412 |
+
|
| 1413 |
+
354
|
| 1414 |
+
00:29:02,000 --> 00:29:08,000
|
| 1415 |
+
We learned list of the most common spring boot properties and default values for some of them.
|
| 1416 |
+
|
| 1417 |
+
355
|
| 1418 |
+
00:29:09,000 --> 00:29:16,000
|
| 1419 |
+
Now you know how to change port number, how to configure SSL, TLS and spring boot application.
|
| 1420 |
+
|
| 1421 |
+
356
|
| 1422 |
+
00:29:17,000 --> 00:29:24,000
|
| 1423 |
+
On real example, you saw how you can generate Self-signed certificate with changed context pass of
|
| 1424 |
+
|
| 1425 |
+
357
|
| 1426 |
+
00:29:24,000 --> 00:29:25,000
|
| 1427 |
+
the application.
|
| 1428 |
+
|
| 1429 |
+
358
|
| 1430 |
+
00:29:25,000 --> 00:29:32,000
|
| 1431 |
+
Also, we configured login level and at the end of the lesson we learned how to work with configuration
|
| 1432 |
+
|
| 1433 |
+
359
|
| 1434 |
+
00:29:32,000 --> 00:29:34,000
|
| 1435 |
+
properties annotation.
|
| 1436 |
+
|
| 1437 |
+
360
|
| 1438 |
+
00:29:34,000 --> 00:29:35,000
|
| 1439 |
+
That's it.
|
| 1440 |
+
|
| 1441 |
+
361
|
| 1442 |
+
00:29:35,000 --> 00:29:37,000
|
| 1443 |
+
Thanks a lot for your attention.
|
| 1444 |
+
|
| 1445 |
+
362
|
| 1446 |
+
00:29:37,000 --> 00:29:40,000
|
| 1447 |
+
Have a great day and see you in the next lesson.
|
| 1448 |
+
|
92 - Spring Boot/005 Source-code-of-examples-commit-with-changes-.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/AndriiPiatakha/java-learnit-spring-boot/commit/94ba22d51d1e1413056b7fc6bd1f4722ef39c0f5
|
92 - Spring Boot/005 Spring Boot Actuator - Monitoring Tools_en.srt
ADDED
|
@@ -0,0 +1,1184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:05,000 --> 00:00:06,000
|
| 3 |
+
Hello team.
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:06,000 --> 00:00:10,000
|
| 7 |
+
In this video lesson we are going to learn spring boot actuator.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:10,000 --> 00:00:15,000
|
| 11 |
+
We are going to start this lesson from understanding of what spring boot actuator is.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:16,000 --> 00:00:23,000
|
| 15 |
+
I will explain you the key features of actuator and what benefits we expect to get by using it in our
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:23,000 --> 00:00:25,000
|
| 19 |
+
spring boot application.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:25,000 --> 00:00:32,000
|
| 23 |
+
Then we will hold an overview of the existing predefined and points in spring boot actuator.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:32,000 --> 00:00:37,000
|
| 27 |
+
After learning the theory, we are going to have a practical examples and demo.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:37,000 --> 00:00:44,000
|
| 31 |
+
I will start screen sharing and will show you everything you need to know in order to start work with
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:44,000 --> 00:00:46,000
|
| 35 |
+
spring boot actuator from scratch.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:47,000 --> 00:00:52,000
|
| 39 |
+
We will add required dependency will expose actuator and points.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:52,000 --> 00:00:58,000
|
| 43 |
+
And in case you would like to exclude some end points, I will also show you how you can do this.
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:58,000 --> 00:01:06,000
|
| 47 |
+
We will learn how to change base parts of the actuator and see how we can actually read different application
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:01:06,000 --> 00:01:07,000
|
| 51 |
+
metrics.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:01:07,000 --> 00:01:13,000
|
| 55 |
+
And at the end of the lesson as a summary, we are going to learn best practices of working with Spring
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:01:13,000 --> 00:01:14,000
|
| 59 |
+
boot actuator.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:01:15,000 --> 00:01:17,000
|
| 63 |
+
Let's start our lesson.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:01:17,000 --> 00:01:20,000
|
| 67 |
+
Let's understand first what is spring boot?
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:01:20,000 --> 00:01:29,000
|
| 71 |
+
Actuator actuator plays a crucial role in enhancing our application with production ready capabilities.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:01:29,000 --> 00:01:38,000
|
| 75 |
+
By integrating actuator, we gain the ability to monitor our application, collect metrics, gain insights
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:01:38,000 --> 00:01:42,000
|
| 79 |
+
into traffic, and assess the status of our database.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:01:42,000 --> 00:01:50,000
|
| 83 |
+
The primary advantage of utilizing this feature is that we can leverage enterprise grade tools without
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:01:50,000 --> 00:01:53,000
|
| 87 |
+
the need to develop these functionalities from scratch.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:01:53,000 --> 00:02:01,000
|
| 91 |
+
Actuator serves to expose essential operational details about our running application, including health
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:02:01,000 --> 00:02:08,000
|
| 95 |
+
status metrics, information on data dumps, environment configurations and more.
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:02:08,000 --> 00:02:15,000
|
| 99 |
+
It offers various methods for interaction such as HTTP endpoints and jmax beans.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:02:16,000 --> 00:02:18,000
|
| 103 |
+
What are Jmax beans, by the way?
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:02:19,000 --> 00:02:22,000
|
| 107 |
+
Jmax stands for Java Management Extensions.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:02:22,000 --> 00:02:27,000
|
| 111 |
+
Beans, also known as beans Managed beans.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:02:28,000 --> 00:02:36,000
|
| 115 |
+
They are Java objects that are exposed from management and monitoring purposes through the technology.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:02:36,000 --> 00:02:44,000
|
| 119 |
+
Jmax is a standard Java technology for managing and monitoring applications, devices and services in
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:02:44,000 --> 00:02:46,000
|
| 123 |
+
a distributed environment.
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:02:46,000 --> 00:02:53,000
|
| 127 |
+
Once actuator is included in our classpath, a set of preconfigured endpoints become available to us.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:02:53,000 --> 00:03:02,000
|
| 131 |
+
As is typical with spring modules, actuator can be easily customized and extended to meet our specific
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:03:02,000 --> 00:03:05,000
|
| 135 |
+
requirements in many different ways.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:03:05,000 --> 00:03:12,000
|
| 139 |
+
So to sum it up, Spring boot Actuator is a sub project of spring boot that provides production ready
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:03:12,000 --> 00:03:18,000
|
| 143 |
+
features to monitor, manage and interact with spring boot applications.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:03:18,000 --> 00:03:25,000
|
| 147 |
+
It offers a wide range of built in endpoints that expose various operational information and statistics
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:03:25,000 --> 00:03:33,000
|
| 151 |
+
about the application, allowing developers and system administrators to gain insights into the applications,
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:03:33,000 --> 00:03:37,000
|
| 155 |
+
health metrics, configuration, logging and more.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:03:38,000 --> 00:03:43,000
|
| 159 |
+
Let's now review the key features and benefits of spring boot actuator in order.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:03:43,000 --> 00:03:47,000
|
| 163 |
+
You can understand why you may need to use it.
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:03:47,000 --> 00:03:55,000
|
| 167 |
+
Some key features and benefits of spring boot actuator include health monitoring Actuator includes a
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:03:55,000 --> 00:04:01,000
|
| 171 |
+
health endpoint that provides a simple way to check the health status of the application.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:04:01,000 --> 00:04:07,000
|
| 175 |
+
It can indicate whether the application is running properly or if there are any issues.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:04:08,000 --> 00:04:15,000
|
| 179 |
+
Metrics gathering actuator collects and exposes application level metrics through the metrics and point.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:04:15,000 --> 00:04:23,000
|
| 183 |
+
It provides valuable insights into important metrics such as request response rates, CPU and memory
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:04:23,000 --> 00:04:28,000
|
| 187 |
+
usage, database connections and other custom defined metrics.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:04:29,000 --> 00:04:37,000
|
| 191 |
+
Configuration management Actuator offers an environment endpoint that displays the application's current
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:04:37,000 --> 00:04:40,000
|
| 195 |
+
environment, properties and configurations.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:04:40,000 --> 00:04:47,000
|
| 199 |
+
It enables easy inspection and troubleshooting of the application's configuration at runtime.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:04:47,000 --> 00:04:55,000
|
| 203 |
+
The login management actuator provides a logger endpoint that allows dynamic modification of the application's
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:04:55,000 --> 00:04:57,000
|
| 207 |
+
logging levels.
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:04:57,000 --> 00:05:03,000
|
| 211 |
+
It enables runtime control over logging levels without requiring application restarts.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:05:04,000 --> 00:05:12,000
|
| 215 |
+
Request tracing the trace point captures and displays, request tracing information, providing visibility
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:05:12,000 --> 00:05:16,000
|
| 219 |
+
into the flow of requests through the application.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:05:16,000 --> 00:05:21,000
|
| 223 |
+
It can be useful for debugging and understanding request related issues.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:05:22,000 --> 00:05:31,000
|
| 227 |
+
Auditing actuator includes an audit events endpoint that shows auditing related events such as user
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:05:31,000 --> 00:05:36,000
|
| 231 |
+
authentication and authorization events logged by the application.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:05:36,000 --> 00:05:41,000
|
| 235 |
+
It assists in monitoring and tracking security related activities.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:05:42,000 --> 00:05:50,000
|
| 239 |
+
Extensibility Actuator allows the creation of custom endpoints to expose application specific information
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:05:50,000 --> 00:05:53,000
|
| 243 |
+
or perform custom management tasks.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:05:53,000 --> 00:06:00,000
|
| 247 |
+
It provides flexibility to integrate additional functionality based on specific application requirements.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:06:00,000 --> 00:06:07,000
|
| 251 |
+
Spring boot actuator integrates seamlessly with spring boot applications and can be easily configured
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:06:07,000 --> 00:06:10,000
|
| 255 |
+
through properties or annotations.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:06:10,000 --> 00:06:17,000
|
| 259 |
+
It enhances the operational capabilities of spring boot applications, making them easier to monitor,
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:06:17,000 --> 00:06:21,000
|
| 263 |
+
manage and maintain in production environments.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:06:21,000 --> 00:06:28,000
|
| 267 |
+
So you can see that spring boot actuator simplifies the task of managing and monitoring spring boot
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:06:28,000 --> 00:06:36,000
|
| 271 |
+
applications by providing a comprehensive set of out-of-the-box features and endpoints, allowing developers
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:06:36,000 --> 00:06:43,000
|
| 275 |
+
and administrators to gain valuable insights into application health, performance and configuration
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:06:43,000 --> 00:06:44,000
|
| 279 |
+
details.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:06:44,000 --> 00:06:51,000
|
| 283 |
+
Before we jump to practical examples, let me make an overview of some of the predefined endpoints that
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:06:51,000 --> 00:06:54,000
|
| 287 |
+
you can use to monitor your application.
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:06:54,000 --> 00:07:00,000
|
| 291 |
+
We are going to learn Siri now and then we'll jump to practical examples.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:07:00,000 --> 00:07:07,000
|
| 295 |
+
As you can see on the slide, all actuators and points are located on the actuator pass.
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:07:08,000 --> 00:07:13,000
|
| 299 |
+
You can use this information to configure security rules for these end points.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:07:13,000 --> 00:07:16,000
|
| 303 |
+
In order to restrict public access to them.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:07:16,000 --> 00:07:22,000
|
| 307 |
+
Also, I'm going to show you today how to change this base pass, if you wish.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:07:22,000 --> 00:07:30,000
|
| 311 |
+
Helsing Point provides information about the health status of the application indicating if it's running
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:07:30,000 --> 00:07:33,000
|
| 315 |
+
properly or if there are any issues.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:07:34,000 --> 00:07:38,000
|
| 319 |
+
Info endpoint displays custom application information.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:07:38,000 --> 00:07:44,000
|
| 323 |
+
You can configure and customize the details exposed by this endpoint.
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:07:44,000 --> 00:07:53,000
|
| 327 |
+
Metrics and point offers access to a wide range of application metrics such as request response rates,
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:07:53,000 --> 00:07:58,000
|
| 331 |
+
CPU and memory usage, database connections and more.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:07:58,000 --> 00:08:06,000
|
| 335 |
+
Environment endpoint shows the application's current environment properties and configurations providing
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:08:06,000 --> 00:08:09,000
|
| 339 |
+
insights into the runtime configuration of the application.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:08:10,000 --> 00:08:17,000
|
| 343 |
+
Login endpoint allows dynamic modification of the login levels of the application at runtime.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:08:17,000 --> 00:08:23,000
|
| 347 |
+
It enables controlling the log output without requiring application restarts.
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:08:23,000 --> 00:08:31,000
|
| 351 |
+
Trace and point, captures and displays, request tracing information, providing visibility into the
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:08:31,000 --> 00:08:35,000
|
| 355 |
+
flow of requests through the application.
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:08:35,000 --> 00:08:38,000
|
| 359 |
+
It aids in debugging and troubleshooting.
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:08:39,000 --> 00:08:47,000
|
| 363 |
+
Audit events, endpoint presents auditing related events such as user authentication and authorization
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:08:47,000 --> 00:08:49,000
|
| 367 |
+
events logged by the application.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:08:50,000 --> 00:08:57,000
|
| 371 |
+
Beans and point provides information about spring beans registered in the application context, including
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:08:57,000 --> 00:09:00,000
|
| 375 |
+
their dependencies and configurations.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:09:01,000 --> 00:09:02,000
|
| 379 |
+
Conditions.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:09:02,000 --> 00:09:09,000
|
| 383 |
+
End Point displays the conditions that influence the autoconfiguration of the applications bins.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:09:10,000 --> 00:09:17,000
|
| 387 |
+
Mappings endpoint shows a detailed mapping of all the request mappings defined in the application,
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:09:17,000 --> 00:09:21,000
|
| 391 |
+
including the controller methods and their respective URLs.
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:09:22,000 --> 00:09:28,000
|
| 395 |
+
Shut down endpoint enables graceful shutdown of the application by default.
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:09:28,000 --> 00:09:33,000
|
| 399 |
+
It is not enabled and requires explicit configuration for security reasons.
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:09:34,000 --> 00:09:40,000
|
| 403 |
+
Some other predefined endpoints and their descriptions you can see on the slide.
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:09:40,000 --> 00:09:45,000
|
| 407 |
+
Feel free to press pause for a minute to explore the slide slowly.
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:09:45,000 --> 00:09:50,000
|
| 411 |
+
I believe there is no need for me to read all the slides out loud.
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:09:50,000 --> 00:09:58,000
|
| 415 |
+
Please note that availability and visibility of these endpoints may vary based on the actuator configuration
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:09:58,000 --> 00:10:02,000
|
| 419 |
+
and any security settings in place today.
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:10:02,000 --> 00:10:10,000
|
| 423 |
+
During the demo we are going to configure everything what we need to get access to mentioned endpoints.
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:10:10,000 --> 00:10:16,000
|
| 427 |
+
I believe that we learned enough theory and now we are ready to jump to practical examples in order
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:10:16,000 --> 00:10:19,000
|
| 431 |
+
to see spring boot actuator in action.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:10:19,000 --> 00:10:25,000
|
| 435 |
+
So let me show you how to configure actuator in your spring boot project.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:10:25,000 --> 00:10:32,000
|
| 439 |
+
I open Pom.xml file and I add spring boot starter actuator dependency.
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:10:32,000 --> 00:10:36,000
|
| 443 |
+
That's all what you have to add from the dependency side.
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:10:36,000 --> 00:10:40,000
|
| 447 |
+
Now let me open application properties.
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:10:40,000 --> 00:10:41,000
|
| 451 |
+
Don't worry.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:10:41,000 --> 00:10:46,000
|
| 455 |
+
As usual, I will share with you a link to the source code in attachments to the video.
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:10:46,000 --> 00:10:52,000
|
| 459 |
+
So by default, not all endpoints of the actuator are exposed.
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:10:52,000 --> 00:11:00,000
|
| 463 |
+
In case you want to expose all endpoints, you need to specify this property management endpoints Web
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:11:00,000 --> 00:11:04,000
|
| 467 |
+
exposure include and asterisk as a value.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:11:05,000 --> 00:11:08,000
|
| 471 |
+
Asterisk means all endpoints.
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:11:08,000 --> 00:11:15,000
|
| 475 |
+
If you don't want to expose all endpoints, then you can list end points separated by commas like you
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:11:15,000 --> 00:11:18,000
|
| 479 |
+
can see in this commanded example.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:11:18,000 --> 00:11:22,000
|
| 483 |
+
But I will keep all endpoints exposed for the sake of the demo.
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:11:23,000 --> 00:11:30,000
|
| 487 |
+
In case you want to exclude some end points, you need to use exposure, exclude property.
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:11:30,000 --> 00:11:37,000
|
| 491 |
+
And in the similar way, in case you need to exclude multiple end points, you can pass comma separated
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:11:37,000 --> 00:11:41,000
|
| 495 |
+
list of values like you can see in this commanded example.
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:11:42,000 --> 00:11:45,000
|
| 499 |
+
The next property here is health.
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:11:45,000 --> 00:11:46,000
|
| 503 |
+
Show details.
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:11:47,000 --> 00:11:49,000
|
| 507 |
+
Let me tell you more about it.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:11:50,000 --> 00:11:56,000
|
| 511 |
+
This property in spring boot actuator controls the level of detail displayed in the health endpoint
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:11:56,000 --> 00:11:57,000
|
| 515 |
+
response.
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:11:57,000 --> 00:12:06,000
|
| 519 |
+
It determines whether or not to include detailed information about the health status of individual components
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:12:06,000 --> 00:12:07,000
|
| 523 |
+
or subsystems.
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:12:07,000 --> 00:12:12,000
|
| 527 |
+
The possible values for this property are always.
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:12:12,000 --> 00:12:20,000
|
| 531 |
+
This value indicates the detailed health information should always be shown in the health endpoint response.
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:12:20,000 --> 00:12:27,000
|
| 535 |
+
It includes information about the health status of each individual component or subsystem, along with
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:12:27,000 --> 00:12:33,000
|
| 539 |
+
additional details such as error messages or diagnostic information.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:12:33,000 --> 00:12:35,000
|
| 543 |
+
When authorized.
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:12:35,000 --> 00:12:43,000
|
| 547 |
+
This value specifies the detailed health information should only be shown when the requester is authorized
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:12:43,000 --> 00:12:44,000
|
| 551 |
+
to access it.
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:12:44,000 --> 00:12:52,000
|
| 555 |
+
This allows you to restrict access to detailed health information based on authentication and authorization
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:12:52,000 --> 00:12:53,000
|
| 559 |
+
rules.
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:12:53,000 --> 00:12:54,000
|
| 563 |
+
Never.
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:12:54,000 --> 00:13:01,000
|
| 567 |
+
This value means that detailed health information should never be shown in the health endpoint response.
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:13:01,000 --> 00:13:06,000
|
| 571 |
+
Only the high level health status, such as up or down, will be returned.
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:13:07,000 --> 00:13:14,000
|
| 575 |
+
By setting management and point health show details to always you ensure that health endpoint response
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:13:14,000 --> 00:13:20,000
|
| 579 |
+
includes detailed information regardless of the requesters authorization.
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:13:20,000 --> 00:13:26,000
|
| 583 |
+
This can be helpful during the development or troubleshooting scenarios when you need more visibility
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:13:26,000 --> 00:13:29,000
|
| 587 |
+
into the health status of individual components.
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:13:30,000 --> 00:13:35,000
|
| 591 |
+
The next commanded property here is management endpoints, web based POS.
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:13:36,000 --> 00:13:43,000
|
| 595 |
+
It determines the common prefix that is added to the POS of each actuator endpoint.
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:13:43,000 --> 00:13:51,000
|
| 599 |
+
You already learned that base POS for all API in actuator is basically actuator, but you can change
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:13:51,000 --> 00:13:52,000
|
| 603 |
+
it if you wish.
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:13:53,000 --> 00:14:01,000
|
| 607 |
+
So in case I would uncomment this property, the base POS would be management by customizing the base
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:14:01,000 --> 00:14:01,000
|
| 611 |
+
paths.
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:14:01,000 --> 00:14:10,000
|
| 615 |
+
You can align the actuator endpoints URL structure with the rest of your application API or match your
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:14:10,000 --> 00:14:12,000
|
| 619 |
+
desired POS conventions.
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:14:12,000 --> 00:14:16,000
|
| 623 |
+
Another interesting thing is creation of groups.
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:14:16,000 --> 00:14:23,000
|
| 627 |
+
We can organize health indicators into groups and apply the same configuration to all the group members.
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:14:23,000 --> 00:14:30,000
|
| 631 |
+
For example, we can create a health group named Custom by adding this to our application properties
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:14:30,000 --> 00:14:32,000
|
| 635 |
+
like you can see here on the screen.
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:14:33,000 --> 00:14:39,000
|
| 639 |
+
In this case, the custom group contains the disk space and pink health indicators.
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:14:40,000 --> 00:14:47,000
|
| 643 |
+
We can configure the group to show more details in the similar way we already did with the health endpoint.
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:14:47,000 --> 00:14:51,000
|
| 647 |
+
And few more words about show components property.
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:14:51,000 --> 00:14:58,000
|
| 651 |
+
When you create custom health indicators in your application, they can be included in the details group
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:14:58,000 --> 00:15:00,000
|
| 655 |
+
by default.
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:15:00,000 --> 00:15:08,000
|
| 659 |
+
However, by setting management end point health group custom show components to always you are instructing
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:15:08,000 --> 00:15:16,000
|
| 663 |
+
actuator to include the components of the custom group in the response of the health end point regardless
|
| 664 |
+
|
| 665 |
+
167
|
| 666 |
+
00:15:16,000 --> 00:15:19,000
|
| 667 |
+
of their individual health status.
|
| 668 |
+
|
| 669 |
+
168
|
| 670 |
+
00:15:19,000 --> 00:15:26,000
|
| 671 |
+
This property is useful when you want to expose specific components or aspects of your applications.
|
| 672 |
+
|
| 673 |
+
169
|
| 674 |
+
00:15:26,000 --> 00:15:33,000
|
| 675 |
+
Health status in the actuator health endpoint response even if they're in custom group.
|
| 676 |
+
|
| 677 |
+
170
|
| 678 |
+
00:15:33,000 --> 00:15:42,000
|
| 679 |
+
By setting it to always you ensure that the components of the custom group will always be visible regardless
|
| 680 |
+
|
| 681 |
+
171
|
| 682 |
+
00:15:42,000 --> 00:15:44,000
|
| 683 |
+
of their individual health status.
|
| 684 |
+
|
| 685 |
+
172
|
| 686 |
+
00:15:45,000 --> 00:15:48,000
|
| 687 |
+
Basically that's all configuration that we had to do.
|
| 688 |
+
|
| 689 |
+
173
|
| 690 |
+
00:15:48,000 --> 00:15:51,000
|
| 691 |
+
So now you can run your server.
|
| 692 |
+
|
| 693 |
+
174
|
| 694 |
+
00:15:51,000 --> 00:15:54,000
|
| 695 |
+
My server is up and running already.
|
| 696 |
+
|
| 697 |
+
175
|
| 698 |
+
00:15:54,000 --> 00:15:58,000
|
| 699 |
+
Let me switch to the Chrome browser to make some demo.
|
| 700 |
+
|
| 701 |
+
176
|
| 702 |
+
00:15:58,000 --> 00:16:05,000
|
| 703 |
+
Spring Boot includes a discovery endpoint that provides links to all available actuator endpoints,
|
| 704 |
+
|
| 705 |
+
177
|
| 706 |
+
00:16:05,000 --> 00:16:10,000
|
| 707 |
+
simplifying the process of discovering the endpoints and their associated URLs.
|
| 708 |
+
|
| 709 |
+
178
|
| 710 |
+
00:16:10,000 --> 00:16:18,000
|
| 711 |
+
By default, this discovery endpoint can be accessed through the actuator endpoint and you already know
|
| 712 |
+
|
| 713 |
+
179
|
| 714 |
+
00:16:18,000 --> 00:16:20,000
|
| 715 |
+
how to change this basic path.
|
| 716 |
+
|
| 717 |
+
180
|
| 718 |
+
00:16:20,000 --> 00:16:23,000
|
| 719 |
+
We have just reviewed configuration for that.
|
| 720 |
+
|
| 721 |
+
181
|
| 722 |
+
00:16:24,000 --> 00:16:31,000
|
| 723 |
+
The JSON shows a collection of available actuator endpoints along with their corresponding URLs.
|
| 724 |
+
|
| 725 |
+
182
|
| 726 |
+
00:16:32,000 --> 00:16:35,000
|
| 727 |
+
Let's now check some specific endpoints.
|
| 728 |
+
|
| 729 |
+
183
|
| 730 |
+
00:16:35,000 --> 00:16:38,000
|
| 731 |
+
For example, let's check how endpoint.
|
| 732 |
+
|
| 733 |
+
184
|
| 734 |
+
00:16:38,000 --> 00:16:45,000
|
| 735 |
+
It provides information about the health status of various components or subsystems in the application.
|
| 736 |
+
|
| 737 |
+
185
|
| 738 |
+
00:16:45,000 --> 00:16:51,000
|
| 739 |
+
And just to remind you that in case you want to have more readable view of this information, there
|
| 740 |
+
|
| 741 |
+
186
|
| 742 |
+
00:16:51,000 --> 00:16:55,000
|
| 743 |
+
are multiple JSON beautifier tools that you can find online.
|
| 744 |
+
|
| 745 |
+
187
|
| 746 |
+
00:16:56,000 --> 00:17:03,000
|
| 747 |
+
You can copy JSON response and paste it in another tool in order to see readable format and explore
|
| 748 |
+
|
| 749 |
+
188
|
| 750 |
+
00:17:03,000 --> 00:17:04,000
|
| 751 |
+
the content.
|
| 752 |
+
|
| 753 |
+
189
|
| 754 |
+
00:17:04,000 --> 00:17:12,000
|
| 755 |
+
Here is what the response shows Status, the overall health status of the application which is indicated
|
| 756 |
+
|
| 757 |
+
190
|
| 758 |
+
00:17:12,000 --> 00:17:13,000
|
| 759 |
+
as app.
|
| 760 |
+
|
| 761 |
+
191
|
| 762 |
+
00:17:13,000 --> 00:17:19,000
|
| 763 |
+
In this case, it signifies that the application is functioning properly.
|
| 764 |
+
|
| 765 |
+
192
|
| 766 |
+
00:17:19,000 --> 00:17:20,000
|
| 767 |
+
Components.
|
| 768 |
+
|
| 769 |
+
193
|
| 770 |
+
00:17:20,000 --> 00:17:27,000
|
| 771 |
+
It contains detailed information about individual components or subsystems and their health status.
|
| 772 |
+
|
| 773 |
+
194
|
| 774 |
+
00:17:28,000 --> 00:17:36,000
|
| 775 |
+
DB represents a component named DB and its health status, which is up in this example.
|
| 776 |
+
|
| 777 |
+
195
|
| 778 |
+
00:17:36,000 --> 00:17:44,000
|
| 779 |
+
It also includes additional details about the component, such as the database being used and the validation
|
| 780 |
+
|
| 781 |
+
196
|
| 782 |
+
00:17:44,000 --> 00:17:44,000
|
| 783 |
+
query.
|
| 784 |
+
|
| 785 |
+
197
|
| 786 |
+
00:17:45,000 --> 00:17:54,000
|
| 787 |
+
Disk space represents a component named disk space and its health status, which is up in this case.
|
| 788 |
+
|
| 789 |
+
198
|
| 790 |
+
00:17:54,000 --> 00:18:02,000
|
| 791 |
+
It provides details about the disk space, including the total space free space threshold file path
|
| 792 |
+
|
| 793 |
+
199
|
| 794 |
+
00:18:02,000 --> 00:18:04,000
|
| 795 |
+
and whether it exists.
|
| 796 |
+
|
| 797 |
+
200
|
| 798 |
+
00:18:05,000 --> 00:18:13,000
|
| 799 |
+
Pink represents a component named Pink and its health status, which is up in this example groups.
|
| 800 |
+
|
| 801 |
+
201
|
| 802 |
+
00:18:13,000 --> 00:18:17,000
|
| 803 |
+
Do you remember we configured custom group in application properties.
|
| 804 |
+
|
| 805 |
+
202
|
| 806 |
+
00:18:17,000 --> 00:18:24,000
|
| 807 |
+
So here is a confirmation of the fact that we have custom group and we can send requests to the endpoint
|
| 808 |
+
|
| 809 |
+
203
|
| 810 |
+
00:18:24,000 --> 00:18:28,000
|
| 811 |
+
of the group to see the state of only preconfigured components.
|
| 812 |
+
|
| 813 |
+
204
|
| 814 |
+
00:18:29,000 --> 00:18:36,000
|
| 815 |
+
Overall, the actuator health endpoint provides a snapshot of the health status of various components
|
| 816 |
+
|
| 817 |
+
205
|
| 818 |
+
00:18:36,000 --> 00:18:43,000
|
| 819 |
+
in the application, allowing you to monitor and assess the overall health and availability of your
|
| 820 |
+
|
| 821 |
+
206
|
| 822 |
+
00:18:43,000 --> 00:18:43,000
|
| 823 |
+
system.
|
| 824 |
+
|
| 825 |
+
207
|
| 826 |
+
00:18:44,000 --> 00:18:50,000
|
| 827 |
+
Taking into account we have the group configured, we can send requests to the health custom endpoint
|
| 828 |
+
|
| 829 |
+
208
|
| 830 |
+
00:18:50,000 --> 00:18:54,000
|
| 831 |
+
and explore the details in the application properties.
|
| 832 |
+
|
| 833 |
+
209
|
| 834 |
+
00:18:54,000 --> 00:18:59,000
|
| 835 |
+
We configure it only two components for this group disk space and ping.
|
| 836 |
+
|
| 837 |
+
210
|
| 838 |
+
00:18:59,000 --> 00:19:02,000
|
| 839 |
+
And here we can see only two components.
|
| 840 |
+
|
| 841 |
+
211
|
| 842 |
+
00:19:03,000 --> 00:19:05,000
|
| 843 |
+
Now let's check metrics endpoint.
|
| 844 |
+
|
| 845 |
+
212
|
| 846 |
+
00:19:06,000 --> 00:19:11,000
|
| 847 |
+
As you can see, this endpoint replies us with a list of metrics that we can check.
|
| 848 |
+
|
| 849 |
+
213
|
| 850 |
+
00:19:12,000 --> 00:19:17,000
|
| 851 |
+
You can select the metrics that you are interested in and put it into the URL.
|
| 852 |
+
|
| 853 |
+
214
|
| 854 |
+
00:19:18,000 --> 00:19:22,000
|
| 855 |
+
For example, let's check amount of current sessions.
|
| 856 |
+
|
| 857 |
+
215
|
| 858 |
+
00:19:22,000 --> 00:19:31,000
|
| 859 |
+
We take the metric name, which is Tomcat sessions, active current and put it into the URL and we can
|
| 860 |
+
|
| 861 |
+
216
|
| 862 |
+
00:19:31,000 --> 00:19:34,000
|
| 863 |
+
see the response with the details.
|
| 864 |
+
|
| 865 |
+
217
|
| 866 |
+
00:19:34,000 --> 00:19:38,000
|
| 867 |
+
We can see that there is one active session currently.
|
| 868 |
+
|
| 869 |
+
218
|
| 870 |
+
00:19:38,000 --> 00:19:45,000
|
| 871 |
+
By monitoring this metric, you can gain insights into the workload and utilization of session related
|
| 872 |
+
|
| 873 |
+
219
|
| 874 |
+
00:19:45,000 --> 00:19:48,000
|
| 875 |
+
resources in your Tomcat server.
|
| 876 |
+
|
| 877 |
+
220
|
| 878 |
+
00:19:48,000 --> 00:19:56,000
|
| 879 |
+
It can help you understand the current session activity, track the usage of several resources and identify
|
| 880 |
+
|
| 881 |
+
221
|
| 882 |
+
00:19:56,000 --> 00:20:04,000
|
| 883 |
+
any potential issues related to session management, such as an excessive session creation or improper
|
| 884 |
+
|
| 885 |
+
222
|
| 886 |
+
00:20:04,000 --> 00:20:05,000
|
| 887 |
+
session handling.
|
| 888 |
+
|
| 889 |
+
223
|
| 890 |
+
00:20:06,000 --> 00:20:12,000
|
| 891 |
+
Or let's now check another metric metric that is called gvm info.
|
| 892 |
+
|
| 893 |
+
224
|
| 894 |
+
00:20:12,000 --> 00:20:16,000
|
| 895 |
+
The metric provides information about the Gvm version.
|
| 896 |
+
|
| 897 |
+
225
|
| 898 |
+
00:20:16,000 --> 00:20:20,000
|
| 899 |
+
The available tags provide additional details about the vendor.
|
| 900 |
+
|
| 901 |
+
226
|
| 902 |
+
00:20:21,000 --> 00:20:29,000
|
| 903 |
+
Eclipse Adoption Runtime, OpenGL runtime, environment and version associated with the gvm.
|
| 904 |
+
|
| 905 |
+
227
|
| 906 |
+
00:20:29,000 --> 00:20:36,000
|
| 907 |
+
This metric can be useful for monitoring and understanding the Gvm environment in which your application
|
| 908 |
+
|
| 909 |
+
228
|
| 910 |
+
00:20:36,000 --> 00:20:37,000
|
| 911 |
+
is running.
|
| 912 |
+
|
| 913 |
+
229
|
| 914 |
+
00:20:37,000 --> 00:20:41,000
|
| 915 |
+
Using the similar approach, you can check other metrics.
|
| 916 |
+
|
| 917 |
+
230
|
| 918 |
+
00:20:41,000 --> 00:20:44,000
|
| 919 |
+
I believe you understood how it works.
|
| 920 |
+
|
| 921 |
+
231
|
| 922 |
+
00:20:44,000 --> 00:20:48,000
|
| 923 |
+
Just spend some time checking different metrics.
|
| 924 |
+
|
| 925 |
+
232
|
| 926 |
+
00:20:48,000 --> 00:20:50,000
|
| 927 |
+
I bet that you can find it useful.
|
| 928 |
+
|
| 929 |
+
233
|
| 930 |
+
00:20:51,000 --> 00:20:55,000
|
| 931 |
+
Those are the key things that I wanted to show you during the demo.
|
| 932 |
+
|
| 933 |
+
234
|
| 934 |
+
00:20:55,000 --> 00:21:01,000
|
| 935 |
+
Also wanted to make a note that you can create custom endpoints in spring boot actuator.
|
| 936 |
+
|
| 937 |
+
235
|
| 938 |
+
00:21:02,000 --> 00:21:10,000
|
| 939 |
+
Actuator allows you to extend its functionality by adding your own custom endpoints to expose additional
|
| 940 |
+
|
| 941 |
+
236
|
| 942 |
+
00:21:10,000 --> 00:21:15,000
|
| 943 |
+
management or monitoring information specific to your application.
|
| 944 |
+
|
| 945 |
+
237
|
| 946 |
+
00:21:15,000 --> 00:21:18,000
|
| 947 |
+
We reviewed what Spring boot actuator is.
|
| 948 |
+
|
| 949 |
+
238
|
| 950 |
+
00:21:19,000 --> 00:21:21,000
|
| 951 |
+
Now you have a better understanding.
|
| 952 |
+
|
| 953 |
+
239
|
| 954 |
+
00:21:22,000 --> 00:21:29,000
|
| 955 |
+
And before I wrap up this lesson, let's discuss best practices for leveraging actuator effectively.
|
| 956 |
+
|
| 957 |
+
240
|
| 958 |
+
00:21:30,000 --> 00:21:36,000
|
| 959 |
+
When discussing best practices for leveraging actuators effectively, there are several key considerations
|
| 960 |
+
|
| 961 |
+
241
|
| 962 |
+
00:21:36,000 --> 00:21:38,000
|
| 963 |
+
to keep in mind.
|
| 964 |
+
|
| 965 |
+
242
|
| 966 |
+
00:21:38,000 --> 00:21:41,000
|
| 967 |
+
Secure actuator endpoints.
|
| 968 |
+
|
| 969 |
+
243
|
| 970 |
+
00:21:42,000 --> 00:21:46,000
|
| 971 |
+
Actuator endpoints provide sensitive information about your application.
|
| 972 |
+
|
| 973 |
+
244
|
| 974 |
+
00:21:46,000 --> 00:21:51,000
|
| 975 |
+
It's crucial to secure these endpoints to prevent unauthorized access.
|
| 976 |
+
|
| 977 |
+
245
|
| 978 |
+
00:21:51,000 --> 00:21:58,000
|
| 979 |
+
You can configure authentication and authorization mechanisms in our spring boot application.
|
| 980 |
+
|
| 981 |
+
246
|
| 982 |
+
00:21:58,000 --> 00:22:05,000
|
| 983 |
+
We have spring security enabled already, and I believe you watched spring security lessons and you
|
| 984 |
+
|
| 985 |
+
247
|
| 986 |
+
00:22:05,000 --> 00:22:10,000
|
| 987 |
+
already can imagine how to secure these endpoints knowing the basic pass.
|
| 988 |
+
|
| 989 |
+
248
|
| 990 |
+
00:22:11,000 --> 00:22:17,000
|
| 991 |
+
You can basically just secure actuator pass and all child pass and that's it.
|
| 992 |
+
|
| 993 |
+
249
|
| 994 |
+
00:22:18,000 --> 00:22:20,000
|
| 995 |
+
Limit exposed endpoints.
|
| 996 |
+
|
| 997 |
+
250
|
| 998 |
+
00:22:21,000 --> 00:22:27,000
|
| 999 |
+
It's recommended to limit the exposed end points to only those that are necessary for monitoring and
|
| 1000 |
+
|
| 1001 |
+
251
|
| 1002 |
+
00:22:27,000 --> 00:22:29,000
|
| 1003 |
+
management purposes.
|
| 1004 |
+
|
| 1005 |
+
252
|
| 1006 |
+
00:22:29,000 --> 00:22:36,000
|
| 1007 |
+
This helps reduce the attack surface and minimizes the risk of exposing sensitive information.
|
| 1008 |
+
|
| 1009 |
+
253
|
| 1010 |
+
00:22:36,000 --> 00:22:38,000
|
| 1011 |
+
How to limit Exposed endpoints.
|
| 1012 |
+
|
| 1013 |
+
254
|
| 1014 |
+
00:22:38,000 --> 00:22:41,000
|
| 1015 |
+
We also learned on examples.
|
| 1016 |
+
|
| 1017 |
+
255
|
| 1018 |
+
00:22:42,000 --> 00:22:50,000
|
| 1019 |
+
Customize and point pass activate endpoints have default paths such as actuator has or actuator info.
|
| 1020 |
+
|
| 1021 |
+
256
|
| 1022 |
+
00:22:50,000 --> 00:22:59,000
|
| 1023 |
+
It's advisable to customize these paths to make them less predictable and less susceptible to potential
|
| 1024 |
+
|
| 1025 |
+
257
|
| 1026 |
+
00:22:59,000 --> 00:23:00,000
|
| 1027 |
+
security vulnerabilities.
|
| 1028 |
+
|
| 1029 |
+
258
|
| 1030 |
+
00:23:00,000 --> 00:23:04,000
|
| 1031 |
+
And we already learned how to adjust the base path.
|
| 1032 |
+
|
| 1033 |
+
259
|
| 1034 |
+
00:23:05,000 --> 00:23:12,000
|
| 1035 |
+
Monitor Essential Metrics Actuator provides various metrics to monitor the health and performance of
|
| 1036 |
+
|
| 1037 |
+
260
|
| 1038 |
+
00:23:12,000 --> 00:23:14,000
|
| 1039 |
+
your application.
|
| 1040 |
+
|
| 1041 |
+
261
|
| 1042 |
+
00:23:14,000 --> 00:23:22,000
|
| 1043 |
+
It identifies the most critical metrics for your specific use case and ensure they're actively monitored.
|
| 1044 |
+
|
| 1045 |
+
262
|
| 1046 |
+
00:23:22,000 --> 00:23:32,000
|
| 1047 |
+
This can include metrics related to request rates, response times, error rates, CPU and memory usage,
|
| 1048 |
+
|
| 1049 |
+
263
|
| 1050 |
+
00:23:32,000 --> 00:23:39,000
|
| 1051 |
+
database connections, and any other relevant metrics specific to your application's behavior.
|
| 1052 |
+
|
| 1053 |
+
264
|
| 1054 |
+
00:23:40,000 --> 00:23:47,000
|
| 1055 |
+
Leverage custom end points Actuator allows you to create custom endpoints to expose application specific
|
| 1056 |
+
|
| 1057 |
+
265
|
| 1058 |
+
00:23:47,000 --> 00:23:49,000
|
| 1059 |
+
monitoring and management information.
|
| 1060 |
+
|
| 1061 |
+
266
|
| 1062 |
+
00:23:50,000 --> 00:23:57,000
|
| 1063 |
+
Consider creating custom endpoints tailored to your applications requirements, providing insights into
|
| 1064 |
+
|
| 1065 |
+
267
|
| 1066 |
+
00:23:57,000 --> 00:24:03,000
|
| 1067 |
+
specific aspects of your system or exposing custom management operations.
|
| 1068 |
+
|
| 1069 |
+
268
|
| 1070 |
+
00:24:04,000 --> 00:24:11,000
|
| 1071 |
+
Utilize health indicators, actuators, health and point provides information about the health of your
|
| 1072 |
+
|
| 1073 |
+
269
|
| 1074 |
+
00:24:11,000 --> 00:24:12,000
|
| 1075 |
+
application.
|
| 1076 |
+
|
| 1077 |
+
270
|
| 1078 |
+
00:24:12,000 --> 00:24:19,000
|
| 1079 |
+
Implement Custom Health indicators to incorporate additional checks specific to your applications,
|
| 1080 |
+
|
| 1081 |
+
271
|
| 1082 |
+
00:24:19,000 --> 00:24:22,000
|
| 1083 |
+
dependencies and critical components.
|
| 1084 |
+
|
| 1085 |
+
272
|
| 1086 |
+
00:24:22,000 --> 00:24:29,000
|
| 1087 |
+
This allows you to have a comprehensive view of the overall health status and proactively address any
|
| 1088 |
+
|
| 1089 |
+
273
|
| 1090 |
+
00:24:29,000 --> 00:24:31,000
|
| 1091 |
+
potential issues.
|
| 1092 |
+
|
| 1093 |
+
274
|
| 1094 |
+
00:24:32,000 --> 00:24:35,000
|
| 1095 |
+
Integrate with monitoring and alerting systems.
|
| 1096 |
+
|
| 1097 |
+
275
|
| 1098 |
+
00:24:36,000 --> 00:24:43,000
|
| 1099 |
+
Actuator complements, monitoring and alerting systems by exposing valuable information about your application.
|
| 1100 |
+
|
| 1101 |
+
276
|
| 1102 |
+
00:24:44,000 --> 00:24:52,000
|
| 1103 |
+
Integrate actuator with your preferred monitoring and alerting tools such as Prometheus, Grafana or
|
| 1104 |
+
|
| 1105 |
+
277
|
| 1106 |
+
00:24:52,000 --> 00:24:53,000
|
| 1107 |
+
Elastic Logstash.
|
| 1108 |
+
|
| 1109 |
+
278
|
| 1110 |
+
00:24:53,000 --> 00:25:00,000
|
| 1111 |
+
Kibana Stack To gain a centralized view of your applications, health metrics and logs.
|
| 1112 |
+
|
| 1113 |
+
279
|
| 1114 |
+
00:25:01,000 --> 00:25:07,000
|
| 1115 |
+
Document, exit and points document the available exit and points.
|
| 1116 |
+
|
| 1117 |
+
280
|
| 1118 |
+
00:25:07,000 --> 00:25:10,000
|
| 1119 |
+
The purpose and the information they provide.
|
| 1120 |
+
|
| 1121 |
+
281
|
| 1122 |
+
00:25:10,000 --> 00:25:19,000
|
| 1123 |
+
This documentation helps both developers and operations teams to understand the capabilities and usage
|
| 1124 |
+
|
| 1125 |
+
282
|
| 1126 |
+
00:25:19,000 --> 00:25:27,000
|
| 1127 |
+
of actuate and points, facilitating effective monitoring, troubleshooting and management of the application.
|
| 1128 |
+
|
| 1129 |
+
283
|
| 1130 |
+
00:25:28,000 --> 00:25:35,000
|
| 1131 |
+
By following these best practices, you can leverage actuator effectively to gain insights into your
|
| 1132 |
+
|
| 1133 |
+
284
|
| 1134 |
+
00:25:35,000 --> 00:25:42,000
|
| 1135 |
+
applications, health metrics and management aspects, enabling efficient monitoring, troubleshooting
|
| 1136 |
+
|
| 1137 |
+
285
|
| 1138 |
+
00:25:42,000 --> 00:25:45,000
|
| 1139 |
+
and optimization of your spring boot applications.
|
| 1140 |
+
|
| 1141 |
+
286
|
| 1142 |
+
00:25:46,000 --> 00:25:49,000
|
| 1143 |
+
That's all what I wanted to review with you today.
|
| 1144 |
+
|
| 1145 |
+
287
|
| 1146 |
+
00:25:49,000 --> 00:25:52,000
|
| 1147 |
+
Let's recap what we have learned in the lesson.
|
| 1148 |
+
|
| 1149 |
+
288
|
| 1150 |
+
00:25:53,000 --> 00:25:56,000
|
| 1151 |
+
We learned what spring boot actuator is.
|
| 1152 |
+
|
| 1153 |
+
289
|
| 1154 |
+
00:25:57,000 --> 00:26:01,000
|
| 1155 |
+
Now you know the key features and benefits of spring boot actuator.
|
| 1156 |
+
|
| 1157 |
+
290
|
| 1158 |
+
00:26:02,000 --> 00:26:08,000
|
| 1159 |
+
I showed you existing predefined endpoints that are available in spring boot actuator.
|
| 1160 |
+
|
| 1161 |
+
291
|
| 1162 |
+
00:26:08,000 --> 00:26:15,000
|
| 1163 |
+
On real examples, you saw how to configure spring boot actuator in your application and how to read
|
| 1164 |
+
|
| 1165 |
+
292
|
| 1166 |
+
00:26:15,000 --> 00:26:17,000
|
| 1167 |
+
applications metrics.
|
| 1168 |
+
|
| 1169 |
+
293
|
| 1170 |
+
00:26:18,000 --> 00:26:23,000
|
| 1171 |
+
And at the end of the lesson, we learned best practices of working with Spring Boot Actuator.
|
| 1172 |
+
|
| 1173 |
+
294
|
| 1174 |
+
00:26:24,000 --> 00:26:25,000
|
| 1175 |
+
That's it.
|
| 1176 |
+
|
| 1177 |
+
295
|
| 1178 |
+
00:26:25,000 --> 00:26:27,000
|
| 1179 |
+
Thanks a lot for your attention.
|
| 1180 |
+
|
| 1181 |
+
296
|
| 1182 |
+
00:26:27,000 --> 00:26:30,000
|
| 1183 |
+
Have a great day and see you in the next lesson.
|
| 1184 |
+
|