简体   繁体   English

Mysql中的微服务实现(关系型数据库结构)

[英]Microservices Implementation in Mysql (Relational database structure)

We have an existing project build with Mysql and Java struts.我们有一个使用 Mysql 和 Java struts 构建的现有项目。 We have to implement the new section(Let's say a CRM) in the project.我们必须在项目中实施新部分(假设是 CRM)。 The current project project we are having Mysql database and it is having around 160 tables and all these tables having connection between each other (Foreign Key relations).当前的项目项目我们有 Mysql 数据库,它有大约 160 个表,所有这些表之间都有连接(外键关系)。

The new Project we are planning to implement using Spring boot Microservices, and on using this with the existing database we are facing some issue on structuring microservices our application.我们计划使用 Spring boot 微服务实施的新项目,并且在将其与现有数据库一起使用时,我们在构建应用程序的微服务方面面临一些问题。

When we are proceeding with microservices we have two options to manage entities当我们继续使用微服务时,我们有两种选择来管理实体

  1. Keep the entity and all the DAO's as a seperate Microservices(Entity Microservice) this will communicate with all microservices.将实体和所有 DAO 保持为单独的微服务(实体微服务),这将与所有微服务进行通信。 In this case the advantage is that, if we have any change in the database structure or field change we only needs to change this Entity microservices since this is using by all the microservices we can manage the entity for the project from a single area在这种情况下,优点是,如果我们对数据库结构或字段进行任何更改,我们只需要更改此实体微服务,因为所有微服务都在使用它,我们可以从一个区域管理项目的实体
  2. We can manage the entities that needed in each microservices in each microservices package itself.我们可以在每个微服务包本身中管理每个微服务所需的实体。 But in that case the advantage is that any of the microservices will not have any connection and each microservice will act as independently.但在那种情况下,优点是任何微服务都不会有任何连接,每个微服务都将独立运行。 But the problem is that when we have a change in(say doctor table) this entity change we have to update in each miccroservices.但问题是,当我们更改(比如医生表)这个实体更改时,我们必须在每个微服务中更新。

Let us know if we have any other project structure that we can use in our project since our database is in mysql and each tables are tightly coupled.让我们知道我们是否有任何其他项目结构可以在我们的项目中使用,因为我们的数据库在 mysql 中并且每个表都是紧密耦合的。

Create a new commons package that contains only entity, dto and util classes.创建一个仅包含实体、dto 和实用程序类的新公共包。

Now make this commons project as dependency jar in all of your microservices project.现在将这个公共项目作为所有微服务项目中的依赖 jar。

Finally, there's no use to initiate commons project as microservice.最后,将公共项目作为微服务启动是没有用的。 To deploy a new microservice that needs commons jar as dependency then make sure you first clone the commons repository and respective repository.要部署需要 commons jar 作为依赖项的新微服务,请确保首先克隆 commons 存储库和相应的存储库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM