简体   繁体   English

Jhipster-将两个应用程序连接到一个数据库

[英]Jhipster - connecting two applications to one database

I have a working Jhipster application, linked to a mysql database. 我有一个工作的Jhipster应用程序,已链接到mysql数据库。
I would like to create a new application that I would connect to the first application database. 我想创建一个新应用程序,该应用程序将连接到第一个应用程序数据库。

Is it possible? 可能吗? regarding to liquibase/entities/etc. 关于liquibase / entities / etc。

Why should this not be possible? 为什么这不可能呢? MySQL itself is a multiuser DBMS, so it could handle multiple connections. MySQL本身是一个多用户DBMS,因此它可以处理多个连接。

The only problem would be liquibase, because it checks if your database is valid against your changelogs. 唯一的问题是liquibase,因为它会检查数据库是否对变更日志有效。 So, if your second app also uses liquibase and has not the same changelogs with same checksums, it will not start. 因此,如果您的第二个应用程序也使用liquibase,并且具有不相同的变更日志和相同的校验和,则它将不会启动。 So your second app should not use liquibase and you should remove the liquibase-stuff from the second app. 因此,您的第二个应用程序不应使用liquibase,而应从第二个应用程序中删除liquibase-stuff。 The means: the first app is repsponsible for creating/updating the schema using liquibase and the second app just uses the same schema. 意思是:第一个应用程序负责使用liquibase创建/更新架构,第二个应用程序仅使用相同的架构。

And you're right: the entities must be the same, because hibernate/JPA assumes the same column and entity/table names (which are given by the database)... 而且您是对的:实体必须相同,因为hibernate / JPA假定列和实体/表名相同(由数据库指定)...

In my opinion, a better approach would be the microservice-way: the first application is the only who access the database directly and offers some interfaces for the entities via REST. 我认为,更好的方法是微服务方式:第一个应用程序是唯一直接访问数据库并通过REST为实体提供一些接口的应用程序。 Then, your second application simply uses the interface via a REST-Client. 然后,您的第二个应用程序仅通过REST-Client使用该接口。 This also allows you to define other/modified entities via the REST-Service and your second app may not use exactly the same like in the first application. 这还允许您通过REST服务定义其他/修改的实体,并且您的第二个应用程序可能不完全像第一个应用程序那样使用。

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

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