Spring Cloud microservice Architecture - getting started creating parent project

I Spring Cloud microservice architecture

1. What is micro service

The foundation of microservice architecture (MSA) is to split a single application into multiple independent small services, which can be developed, deployed and run independently.

2. Core component analysis

Spring Cloud Alibaba provides the following core functions by default (first understand):

Service current limiting degradation:
By default, it supports the access of WebServlet, OpenFeign, RestTemplate, spring cloud gateway and rocketmq current limit and degradation function. It can modify the current limit and degradation rules in real time through the console during operation, and it also supports the view of current limit and degradation Metrics monitoring.
Service registration and discovery:
Based on the Spring Cloud service registration and discovery standard, it is implemented with the help of Nacos. By default, it also integrates the support of Ribbon.
Distributed configuration management:
Nacos supports externalized configuration in distributed system, which will be refreshed automatically when the configuration changes.
Message driven capability:
Build message driven capabilities for microservice applications based on Spring Cloud Stream.
Distributed transactions:
Use @ GlobalTransactional annotation to solve the problem of distributed transactions efficiently and without business intrusion..
Distributed task scheduling:
Provide second level, accurate, highly reliable and highly available timed (based on Cron expression) task scheduling service. At the same time, it provides a distributed task execution model, such as grid tasks. Grid tasks support the uniform distribution of tasks among all workers.

II Engineering structure of spring cloud aggregation project

III Create project and corresponding configuration (idea)

Open Idea and create an empty project named cgbmsc

This empty project (empty folder) will be used as the code workspace

1. Project initialization configuration

Step 1: configure maven environment (reconfigure as long as it is a new workspace). Pay attention to the new location of the local library. Do not share the local library with other projects, because multiple projects need to rely on different versions, and there may be some conflicts between dependent versions.

Note that there should be no spaces between Chinese words in the local library
Step 2: configure JDK compilation environment
During the compilation of aggregation project, the related dependent projects need to be compiled together, so some configurations need to be made as follows

Specify the jdk compiled version of the current workspace as follows

Step 3: configure the item coding method in the workspace

2. Create aggregate parent project

Step 1: create parent project module

Step 2: delete the src file in the project (the parent project does not need this file)

Step 3: modify the POM of the parent project XML file

<!--Unified dependent version(All subprojects will refer to the version definitions here),
        dependencyManagement Element is only responsible for defining dependent versions-->
            <!--definition Spring Boot Dependent version-->
            <!--definition Spring Cloud Dependent version-->
            <!--definition Spring Cloud Alibaba Dependent version-->
    <!--Define public dependencies(Dependencies required by all subprojects,Subsequent sub projects need not be added)-->
                <!--exclude junit4 This group of dependencies-->
    <!--Define a unified compilation and running environment-->

Create a service provider module and inherit the parent project

Create service consumer

Create API gateway service module

Design diagram of service relationship and invocation relationship

Keywords: Java Spring Cloud Microservices

Added by navarre on Thu, 24 Feb 2022 14:30:58 +0200