Spring Boot Microservices Tutorial - Part 1 - Building Services
ฝัง
- เผยแพร่เมื่อ 1 ต.ค. 2024
- In this Spring Boot 3 Microservices tutorial series, we will learn how to build microservices using Spring Boot and Spring Cloud.
This is part 1 of the series, in this part, we will cover:
The High-Level Architecture of the project
The Logical Architecture of the project
Building Product Service
Writing Integration Tests using Test Containers
The tutorial series and the upcoming parts includes some changes below compared to the previous Microservices Series:
- Spring Boot 3
- Integration Tests using Latest Testing Techniques
- Spring Cloud Feign for inter service communication
- API Gateway implementation using Spring Cloud Gateway MVC instead of Spring Cloud Gateway with Webflux
- Add Circuit Breaker Logic in API Gateway
- Security using latest Keycloak
- Distributed Tracing using Grafana Stack instead of Slueth
- Deployment using Kubernetes
Link to Written Tutorial: programmingtechie.com/2024/03/28/spring-boot-microservices-tutorial/
Good day,
Is this the same Microservices course but with Springboot 3?
The tutorial series includes some changes below:
- Spring Boot 3
- Integration Tests using Latest Testing Techniques
- Spring Cloud Feign for inter service communication
- API Gateway implementation using Spring Cloud Gateway MVC instead of Spring Cloud Gateway with Webflux
- Add Circuit Breaker Logic in API Gateway
- Security using latest Keycloak
- Distributed Tracing using Grafana Stack instead of Slueth
- Deployment using Kubernetes
how long will it take to post all the courses, Sir?
Sir, will the entire tutorial be free
When part 2 is coming?
Kindly implement oauth2.0 jwt authorization instead of keyclock this time around
I agree , most systems are utilising oauth2.0 jwt for security implementation
00:03 Building a Spring Boot application using microservices architecture for an online shop
02:08 Implementing various services for order processing and notifications
06:17 Creating a product service using Spring Boot and Maven
08:39 Setting up MongoDB using Docker Compose in Spring Boot Microservices
13:36 Configuring MongoDB URI and creating domain model
15:57 Adding post mapping annotation and creating product request class
20:43 Creating and saving product objects in the repository
22:53 Changing the response type for confirmation of product creation.
27:31 Adding authentication information to MongoDB URI
29:46 Test containers library can spin up Docker containers for real databases for integration testing
33:59 Configuring Rest Assured for application testing
36:08 Creating a test for the product controller endpoint
Crafted by Merlin AI.
Hi,
Am getting AuthenticationFailed for the MongoDB even though I have given the correct entries in the docker-compose.yml and the right connection string in the application.properties. Can you please help me
I am getting the same error, Can't get over it.
I found the problem in my case, I had local instance of mongodb If you have mongodb installed locally uninstall it.
@@saujan6289 or change port on 27018*
@@saujan6289 so I need to uninstall the mongodb locally one in my computer and using only the mongodb in docker instead ?
Had the same issue with an already running instance from the tutorial before. Either stop the old one, or use another port. (Change docker-compose.yml --> port: - "27018:27017" (Host 27018 mapped to 27017 within docker container port))
Error response from daemon: error while creating mount source path '/host_mnt/Users/vietmanh21/Documents/Project/vmshop/product/data/mysql': mkdir /host_mnt/Users/vietmanh21/Documents: operation not permitted
Error when docker compose up -d
I have used ModelMapper but it didn't work with record due to the use of Java records for ProductResponseDto. Java records implicitly declare their fields as final and provide a constructor, getters, equals(), hashCode(), and toString() methods automatically. However, records do not have a no-argument constructor, which ModelMapper requires to instantiate the class.
can someone help me out?
my application is not starting after all configurations+code.
the server connects and then disconnects when i run my app.
im using springboot 3.3.4.
Can someone help me in authenticating the mongodb. Checked everything still getting the error.
These tutorials are pure gold. I started the previous version until the hour 2 when I realised there was a newer version so I'm retracking (enjoyingly) the path until I reach where I left and can continue from there. I can't tell you how much I learnt so far. Thank you !!! This is 5 stars !!!
Is the previous version is same project and can we do modification and continue with newer version?
@@movietrailer3616 Well, not exactly. I should have updated my comment. I haven't finished the newer version yet but the differences can be seen on the architectural diagram. At the end I decided to finish the original version and then start the newer one with that base of knowlege. I must say I met (and still meeting) a lot of issues but I could resolve them all so far, they gave me a lot of training in finding, researching and debugging problems. If you have time constraints just go for the newer version but if you don't, I would recommend you to do as I'm doing. Finishing version one successfully is helping me to understand better the spring mindset and how to address the new issues appearing.
@@favio.romero Thanks for your comment I am going with older version then because newer version got Front End technology like Angular which I am not interested also not sure if I skip the angular part still I can continue in newer version playlist. Best luck to you btw you can refer Github link of you find any difficulty.
@@movietrailer3616 welcome. I skipped the Angular Part of the newer version, I'll replace it with a REACT exercise later on. I didn't uploaded to github yet, when I do I'll let you know.
Hi while hitting post api, i am facing the error authentication failed with error 18 and i tried to give username and password also with authenticationDatabase as admin but it is not working...any suggestions any help??
finally, a new tutorial. I will skip this until full episodes are downloaded, though
Can anyone please explain me why we are not using any @Autowired annotations for object management?
that annotation is one of the injection types in Spring Boot, calling field injection, aswell with others; constructor and setter injection types. However field injection makes some troubles with testing, during last few years Spring devs not recommending its use, instead we use setter or constructor injection types. Best practise is using constructor injection type.
Eagerly waiting for this series thank you Sai for such a great effort
Love From AGRA ❤❤
Can we pls connect, From Agra too. Lets build a project together.
HI guys, I'm doing part testing in product-service so there won't be an error message like this:
java.lang.IllegalArgumentException: JSON input text cannot be null or empty.
while:
package com.msnh.product_service;
import com.msnh.product_service.dto.ProductRequest;
import io.restassured.RestAssured;
import io.restassured.parsing.Parser;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.testcontainers.containers.MongoDBContainer;
import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper;
import java.math.BigDecimal;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class ProductServiceApplicationTests {
@ServiceConnection
static MongoDBContainer mongoDBContainer = new MongoDBContainer("mongo:7.0.7");
@LocalServerPort
private integer port;
private objectMapper objectMapper;
@BeforeEach
empty set() {
RestAssured.baseURI = "localhost";
RestAssured.port = port;
RestAssured.defaultParser = Parser.JSON;
}
static {
mongoDBContainer.start();
}
@Test
void shouldCreateProduct() throws Exception {
ProductRequest productRequest = getProductRequest();
RestAssured.given()
.contentType("application/json")
.body(productRequest)
.When()
.post("/api/product")
.Later()
.log().all()
.statusCode(201)
.body("id", Matchers.notNullValue())
.body("name", Matchers.equalTo(productRequest.name()))
.body("description", Matchers.equalTo(productRequest.description()))
.body("price", Matchers.is(productRequest.price().intValueExact()));
}
private ProductRequest getProductRequest() {
return new ProductRequest("iPhone 13", "iPhone 13 black 512gb", BigDecimal.valueOf(1200));
}
}
please help me
Course is very good brother I was learning from the old series also was good but this one is really great I think
I am very excited about this tutorial. Your explanation is awesome. Good luck
Appreciate all the new content. Question, how is this different from the current playlist you have ? The one you posted a year ago ? Trying to figure out if I should just start with this one or keep watching the old one.
This is the more relevant playlist and more detailed, check the pinned comment
@@ProgrammingTechieappreciate it. Didn’t see the comment 🤦🏻♂️. Your content is very helpful.
HI Sir,
Is this series is free?? Or we need to take subscription.
How many upcoming classes are there??
hi, your graphic is wrong 3:50 and special your arrows for sync. comm and unsync. comm. it make me confius. sync. comm = and unsync. comm = ->....can you straighten that out?
can this project be developed on a macbook Air..looking at so many software components that were used ?
@ProgrammingTechie Your training is awesome, why cant you make udemy course?
IS there a github repo
amazing video bro
Thank you for the videos, Could you please also cover Microservices design patterns and principles
Which one should i continue sir ji .. The previous one that you posted a year back "Apr 23, 2022 Spring Boot Microservices Full Course" or this one ? @ProgrammingTechie
This one
how ide authomatic write code? do tutor, please)
@PragrammingTechie Thanks for creating this series
I followed the same steps for docker. same configuration was added in docker-compose file but still I am facing the below error while executing docker compose up -d command. can anyone guide me here to resolve this issue? Thank in advance!
`version` is obsolete"
error during connect: this error may indicate that the docker daemon is not running
is you docker client running in background ?
Wow that's a great tutorial, can you please add frontend frameworks like React or Angular for this series.
Why Eureka is used when client side server zookeeper is present
Thanks for the video. One suggestion, the font is very small. It's very hard to see in laptop.
It's better from video 4
Did Anyone face any issues with integration tests ?
while writing the test case for shouldCreateProduct method,
it is asking me to typecast it to ResponseAwareMatcher) like this : -
.body("id", (ResponseAwareMatcher) Matchers.notNullValue())
.body("name", (ResponseAwareMatcher) Matchers.equalTo("iphone 15"))
Can someone please help with this ? @ProgrammingTechie
Awesome Tutorial, Thanks a lot Sai..
Cool. Thanks for the course!
Very helpful video! I have one question about your model class: why is it anomic (consisting of a setter, getter, such as a value object) instead of being a rich business entity class (which contains some state, behavior, and validations)?
I want to keep this simple :) , in this tutorial, I am mainly concentrating on the surrounding technologies instead of each individual project.
Please let me know what are the prerequisites that i needed, to complete the tutorial with ease. @ProgrammingTechie
This is the first thing I mentioned in the video, try watching at least the first 10 seconds
where can I get the source code of the course
Can you implement oauth2.0 jwt authorization instead of keyclock this time around
Can you explain more about what you mean ? If you want to use OAuth2 then you have to use any authorization server like Keycloak/Auth0/Okta
You cannot implement OAuth2 without it.
If you want to just have JWT Authentication and Authorization without using Keycloak, then I have to tell you that's not a standard practice in the real world.
JWT auth is used only when you are using monolithic apps.
Thank you man! Very good explanation! Keep going. :D
Thanks a lot! I was waiting for this. Any idea, by when will all the episodes of this tutorial be released? Also, what is the total watch time of this complete series?
Hey, it will take 2 more weeks to release the whole course, I don't know the total watch time, but it will be greater than 6 hours
In 8:06 why you don't take the cloud lib and why u use maven not gradle becous it is faster as maven?
I don't know if Maven is faster than Gradle, for me I am more used to Maven, and I see no reason to switch to Gradle.
What will you use to keep secrets? hashicorp? I think you didn't use it in the other tutorial
We will use kubernetes secrets
Can you explain why did you use mongo with the product service ?
because product data is usually unstructured means every product can have different attributes as we dont need rigid schema for that or proper relationships.
thank you. can you pls do or add aws to it?
I will not be covering this in this series.
Deploying Kubernetes to AWS EKS is first of all not covered in the free tier.
You will be charged for the usage of AWS.
In my paid course I will be covering deployment to cloud with the deployment to GCP.
regarding the paid course, will there be a frontend? like Angular?@@ProgrammingTechie
Hello, will you create frontend for this project? thanks
Frontend is not planned for this series
exactly what i am looking for!!!
Nice video. But the font size is very small, and watching on the laptop is very difficult, please increase the font size in future videos.
I increased the font size in the latest 2 videos, got a new monitor recently that messed up the recording resolution 😔
@@ProgrammingTechie I used my big monitor to watch the video and the laptop screen for IntelliJ. Normally, I do it the other way around, but I switched because of the font size. Anyway, it's not a big problem when you have great content :)
One word::- Wow....such an amazing course.
Good. Thanks for the tutorial!
Thank you so much!
Sai sir what are the prerequisite to start with this i can build a rest api with Spring Boot but hav no exp with k8s should i learn that first ?
No need I will start with basics of k8s
@@ProgrammingTechie Great
Lovely. Thank you for the series Sai.
Thank you for this course ! just want to know why didn't we use a discovery service?
We use Kubernetes for service discovery
@@ProgrammingTechie Thank you for your response, so why dont we call services with their names instead of url? how can we manage multiple instances
@@kunaiEUW Kubernetes manages it by itself if we have multiple instances, it does the load balancing,.
we are using the service names itself, the url is constructed using the service name, if you are making a http call then you have to create a url according to the http specification.
Pure Gem!!!!!!!
excited for playlist
thanks bro!
Thank you
Nice
Awesome I was waiting for this.
Very good Explanation.
when the next part be released?