Do you want to build a micro service project or not?

Time:2021-11-27

This is an introductory problem. To build a microservice project, we first need to build a project and what form the code is organized in. This is the first problem we face.

To clarify buddies brother, the Maven can not be used in the first place. The partners can reply to SSM in the background of public official account, and get Maven tutorial by song brothers.

In traditional projects, we often need to build aggregation projects, which can facilitate the sub module management of the project and reduce the difficulty of maintenance.

In the microservice project, do we still need to continue this development method? Today, SongGe has a brief talk with you about the organization form of code in the microservice project based on his own experience in the project.

1. Development mode

To understand how the code is organized, we must first understand what the microservice architecture looks like!

In the microservice architecture, a complete project is divided into many independent microservices. For example, an e-commerce project may be divided into many microservices, such as commodity management, merchant management, user management, transaction management, SEO management, APP management, financial management, system management and so on.

These micro services are independent projects, which are developed and maintained by different teams.

Different teams develop independently, maintain independently, test independently (depending on the situation) and go online independently, which can effectively improve the development efficiency of the project.

Combined with the actual situation of the project, different teams can even choose different technology stacks, such as Java for commodity management module, go for transaction management, PHP for portal website, etc. from the perspective of microservice architecture, these are supported, which is also one of the advantages of microservice, that is, the same system does not have to stick to the same language. Of course, in specific practice, It also needs to be selected in combination with the team’s technology stack and the characteristics of the language.

In fact, seeing here, you probably understand whether polymerization engineering can still be used here!

2. Polymerization Engineering

First of all, on the whole, that is, the whole project level, we no longer need aggregation engineering. Aggregation engineering can package the project uniformly, solve the dependency problems in the project, and manage the dependent versions uniformly. However, these features are not important for microservice projects.

If the commodity management module uses Java, the transaction management module uses go, and the portal website uses php, it is certainly not necessary to make these three independent microservices into an aggregation project, and you can’t aggregate them. Of course, this is an extreme situation. Even if different microservice modules are developed in Java language, there is no need to aggregate, because different microservices actually run independently and are developed and maintained by different teams. One advantage of microservices is that each team develops independently and does not affect each other. If an aggregation project is carried out, Tied the teams together again.

However, between different micro services, it is inevitable to use some public class libraries, which can be uniformly packaged and uploaded to the company’s Maven private server, and then different teams can rely on them,Or throughgit subtreeTo use

This is from a large level. Specific to each micro service, the advantages of aggregation engineering still exist. It should be used or used. For example, in the commodity management module, aggregation engineering can still be used.

3. Why are there questions

The question of whether to use aggregation engineering in microservices is originally a small problem, but why do many small partners have questions?

Let me tell you a few things I know.

One situation is that the company’s microservices are transformed on the basis of old projects. They are hastily launched, changed and changed. They are beyond recognition. They can’t care about the architecture. It’s ok if the functions can be realized. At this time, aggregation engineering is even used at a large level. As a result, different teams develop them, which still affects the whole body, If a small partner has also developed such a project, there may be questions about the use of aggregation engineering. Brother song has a friend who works on a project of a central enterprise in Guangzhou. This is the case.

Another reason may be that the company has few people. In order to facilitate the development of micro service projects, an aggregation project is made as a whole. In this way, it is very convenient to modify when the project has few people and small quantities.

Buddies, brother, official account of the public address.