Spring Boot Kafka Microservices - #6 - Import and Setup 4 Microservices in IntelliJ IDEA


Welcome to Spring Boot Kafka Event-Driven Microservices Series. In this lecture, we will import all the microservices and do the proper setup in IntelliJ IDEA.

Lecture - #6 - Import and Setup 4 Microservices in IntelliJ IDEA


Transcript:

Hi. Welcome back. In this lecture, we have created 4 microservices as independent Spring Boot projects. In this lecture, we going to import all these 4 Spring Boot projects in the IntelliJ idea. Well, let's go ahead and let's open these files in a folder, all right? And let me copy these four files and let me go to desktop. Well, you can copy the files anywhere you want in your file system, so I'm going to copy them in a desktop and let me quickly unzip these four files. Now, I have these four files over here order service, stock service, email service and base domains. Next, we are going to import these projects in the IntelliJ idea.Well, in case of IntelliJ idea, we'll we can able to open only one folder at a time but I want to open these four folders in the IntelliJ idea so How can do that. Well, what we can do is we can create one parent project within that we can keep these four projects and we can open that parent project from the IntelliJ idea. So let me show you how we can do that. So just create one new folder and let's call it as Spring Boot Kafka Micro Services. All right. And let me copy these four projects and let me paste it in a parent project okay. Now, what we'll do, we will import this parent project in the in IntelliJ IDEA. Well, let's open the IntelliJ IDEA and click on open and go to desktop and here we have Spring Boot Kafka Microservices Project, right? So go ahead and choose this folder and click on Open so this will open this parent project in the IntelliJ IDEA and this parent project or a parent folder has these four projects. Well, as soon as we open this project in IntelliJ IDEA, we'll get an option over here like Maven Build Scripts found okay, so these four projects are in Maven projects, right that's why the IntelliJ IDEA will give this option to load the Maven pom XML changes so we can click on this load to load the XML file of all these four projects okay. So basically in the IntelliJ IDEA, we'll add these four projects as a module to this parent project. So you can go ahead and click on this load icon over here. It will load the XML file of all these four projects. Well, sometime IntelliJ IDEA won't able to load the Maven change for any of the project then what you can do is you can add that project as a module to this main project or a main folder. In order to add a module to this parent folder or main project what you can do is you can select this parent project and go to file project structure and go to module section over here, go to plus and then import module. So you can use this import module section to import any project as a module for this parent project okay. Now, you can see we have four modules order service, stock service, email service and based domains. Well, we have loaded the Maven changes for these four projects that's why you can able to see these project four projects are added as a module to this main project. So sometimes we won't able to load the Maven change for any of the project and you can explicitly add that project as a module to this project great. Now, we have four projects in place. Next, we can able to access these four projects from the single IntelliJ IDEA workspace. Okay, we don't have to switch the workspaces. Let's go ahead and let's change the Embedded Tomcat server port for these three microservices. All right. So by default, Tomcat Server will use the port 8080 right but we cannot deploy all these three microservices in a single port. We have to run these three Spring Boot projects in a three tomcat servers with different ports isn't it. So let's go to order service first and go to application.properties File. Well, by default, Apache Tomcat server will use the port 8080 right So let's keep that port for order service. We will change the port for stock service and email service. So go to stock service, go to application.properties file and just type the property server.port and let's give port as 8081 and just save this file. And next go to email service and go to application.properties file and just type the property server.port equal to 8082 all right. Just save this file. So let's go ahead and let's run the Spring Boot Project. So first run order service. So go to main entry point class. That is OrderServiceApplication. From here we can run the Spring Boot Project. So just enable the Lombok here. Now we can able to see Order Service project is successfully running in embedded Tomcat server, which is running on Port 8080. Next, let's go ahead and let's run the stock service. So let me go to stock service main entry point class over here. And from here I can able to run the Spring Boot Project. And there we go. Stock Service Spring Boot Project is running on Port 8081. Next, let's go to email service Spring Boot Project and go to its main entry point class. From here I can run the Spring Boot Project. And there we go. Email Service. Spring Boot application is also running in Tomcat Server in a port 8082. It means that all these three microservices we can able to run in an embedded tomcat server on different ports. So we don't have to run the base domains project because it is a standalone project. We don't have to run in a tomcat server because we are just going to create the domain entities in the base domains project. We are not going to deploy the server, so we are going to only deploy these three microservices in the embedded Tomcat server. In next lecture, we'll create dto classes in a base domains project. All right. I will see you in the next lecture.

Comments