1 overview

1.1 Individual Architecture vs. Microservice Architecture

  • What is a single architecture
  • What are microservices
  • Microservice characteristics
  • Microservices Panoramic architecture diagram
  • Advantages and disadvantages of microservices
  • Application scenarios of microservices

1.2 Business analysis and modeling

  • Project function demonstration and analysis
  • Microservice unbundling
  • Project Architecture Chart
  • Database design
  • The API documentation

1.3 Writing microservices

  • Create applets
  • Create a project
  • Write user microservices
  • Write content microservices

2 Monomer Application

An archive package (such as a WAR package) that contains all the functional applications is often referred to as a singleton application. The methodology of single application is single application architecture.

  • Architecture diagram

2.1 Advantages of single architecture

  • Architecture is simple
  • Easy to develop, test and deploy

2.2 Disadvantages of single architecture

  • Complexity is high
  • The deployment is slow and the frequency is low
  • Limited scalability
  • Impeding technological innovation

3 the services

The term comes from an article by Martin FowlerMicroservices article

  • translation

    The microservices architecture style is a way to develop a single application asA group of small servicesEach service runs in theOwn processIn, the communication between services is adoptedLightweight communication mechanism(Usually HTTP resources

    API). These servicesBuild around business capabilitiesIt can be independently deployed using the automatic deployment mechanism. These services share oneThe smallest centralized management, services availableDifferent language development, the use ofDifferent data storage technologies

3.1 features

  • Each microservice can run independently in its own process
  • Together, a series of independent, running microservices build the system
  • Each service is an independent business development, and a microservice focuses on a specific function, such as order management, user management, and so on
  • Use of different languages and data storage technologies (project context and team strength)
  • Microservices communicate with each other through lightweight communication mechanisms, such as calls through REST apis;
  • Fully automated deployment mechanism

3.2 Panoramic architecture diagram

3.3 the advantages

  • Individual services are easier to develop and maintain
  • A single microservice starts quickly
  • Local changes are easy to deploy
  • The technology stack is not limited
  • On-demand scaling

3.4 disadvantages

  • Operation and maintenance requirements are high
  • The inherent complexity of distribution
  • Duplication of effort

3.5 Application Scenarios

  • Large, complex projects
  • There is a need for rapid iteration
  • Access pressure

3.6 Not Applicable Scenarios

  • Business is stable
  • Long iteration period

4 Split microservices

4.1 split method

Domain Driven Design (BY Name./ by Verb.)

4.2 Best Practices

Responsibility division universal division

4.3 Reasonable particle size

◆ Satisfied business ◆ Happiness ◆ Incremental iteration ◆ Continuous evolution

  • Break up

  • Project Architecture Chart

5 Database Design

5.1 the data table

6 Create a mini-program

7 front-end code – JavaEdge- MiniAPP

7.1 installation Node. Js

The suggestion is consistent with the author

  • Head over to download Node.js.
  • Download is recommended.
  • Installation instructions
    • MacOS operating system, use PKG directly drag to install

7.2 Modifying APP Information

Modify project.config.json by modifying the following two lines as required

"Appid ":" change to your appid" "projectname": "change to your projectname, try to use English ",Copy the code

Where appID isWechat public platform- Development – Can be found in development Settings.

7.3 Installation & Startup

Install project-related dependency acceleration!

npm --registry https://registry.npm.taobao.org installCopy the code

The development environment starts deployment

npm run devCopy the code

Production environment construction

npm run buildCopy the code

7.4 Download and install the wechat Developer Tools

  • Head over to download developer tools.

  • Install developer tools double click to install!

7.5 Changing the API Call Address

SRC /utils/api.js, found

// Export const BASE_API_URL = ";Copy the code

Change it to your backend address, for example:

export const BASE_API_URL = 'http://localhost:8080';Copy the code

7.6 Importing The Code to the Developer Tool

Note: Be sure not to verify valid domain names… .

8 Creating a Project

8.1 Technology Selection

  • Spring Boot (Rapid iterative Development)
  • Spring MVC (MVC framework) Mybatis (Persistence layer framework, operation database) + universal Mapper
  • Spring Cloud Aliababa

8.3 Structural design of the project

8.4 Framework Integration

8.4.1 MyBatis framework – General Mapper

  • Making the address

Spring integration of the Boot

8.4.1.1 mapper – spring – the boot – the starter

In starter’s logic, if you don’t use the @Mapperscan annotation, you need to add the @Mapper annotation to your interface, otherwise MyBatis won’t be able to determine which interfaces to scan.

The @mapper annotation needs to be added to all interfaces.

  • Adding the starter provided by the universal Mapper completes the most basic integration

  • With this annotation, the universal Mapper will automatically parse all interfaces. If the parent interface (the top layer found recursively) has an interface marked with this annotation, It’s automatically registered. Therefore, after 4.0, when using the methods provided by the universal Mapper, you do not need to configure this parameter.

8.4.1.2 @mapperscan Annotation Configuration

  • Note the MySQL configuration



    8 x with cj

Code generator – MapperGenerator

The generic version is too complex, use the professional version in most cases!

Using this plug-in, you can easily generate entity classes, Mapper interfaces, and corresponding XML files.

This document describes how to use the plug-in in MBG.

For those unfamiliar with MBG, read the documentation below

Mybatis Geneator,

http://blog.csdn.net/isea533/article/details/42102297

Use Maven to perform MBG

  • SB has built-in plug-ins



The plug-in configures the path of the configuration file, overwrite, and output detailed logs.

In addition, it is important to note that all external code used in MBG configuration must be configured in this dependency mode, otherwise the runtime will tell you that the corresponding class cannot be found and an error will be reported. There are two required dependencies, one for the JDBC driver and the other for the Mapper plug-in.

  • Generatorconfig.xml: generatorconfig.xml



    This is pretty much the same as before, except that by introducing an external properties file, the parameters from the properties file are used during configuration.

In the command line window of the pem.xml level directory, run MVN mybatis- Generator :generate (if MVN is configured).

  • When the MyBatis Generator is used, a field in Mapper file is found to be inconsistent with the connected database, and the table is found to be a field in another database with the same name.

    In the construct file, here is Generatorconfig.xml add the connection database parameters as follows:

Integrate Lombok to simplify code

  • Integration in generators

9 Users & Content microservices

Business process analysis

  • Architecture diagram

10 Problems with the existing architecture

  • What if the address changes?
  • How to achieve load balancing?
  • What if the user center fails? .

reference

  • mpvue
  • vant-weapp
  • Mapper
  • Microservices for the Future :Spring Cloud Alibaba from beginner to advanced