简体   繁体   English

使用微服务导入jhipster jdl

[英]jhipster jdl import with microservices

I have a model.jdl with all entities defined like 我有一个model.jdl,所有实体都定义为

entity A{ ... }
entity B{ ... }
entity C{ ... }
entity D{ ... }

and I added some options to distribute this entities in microservices with sometime like this: 并且我添加了一些选项来在微服务中分发此实体,如下所示:

microservice A,B with gateway 
microservice C with app1
microservice D with app2

when I run the "yo jhipster:import-jdl model.jdl" command in the gateway folder, the liquibase's changelog don't include the entities A and B. 当我在网关文件夹中运行“ yo jhipster:import-jdl model.jdl”命令时,liquibase的更改日志不包含实体A和B。

If I run the import in the apps folders, the liquibase changelog show all entities ignoring the distribution defined 如果我在apps文件夹中运行导入,则liquibase changelog将显示所有忽略定义的分布的实体

I tested the model in a monolithic app without the microservices options and works well... 我在没有微服务选项的单片应用程序中测试了模型,并且运行良好。

Here a model for test: 这里是一个测试模型:

entity Car{
    name String required
    color Color
}

enum Color{
    BLACK,WHITE,BLUE,GREEN,YELLOW
}

entity House{
    address String required
}

entity Info{
    phone String required
}

relationship OneToOne{
    Info{user(login) required} to User
}

microservice Info with gateway
microservice Car with app1
microservice House with app2
search * with elasticsearch

Your problem here lies in the with microservice gateway . 您的问题在于with microservice gateway This is not doing what you think it does. 这并没有按照您的想法做。

The microservice keyword is actually used to hint the generator that back-end files should be generated on the microservice and the corresponding front-end files should be generated on the gateway with the correct "URL path prefix". 实际上,使用microservice关键字来提示生成器,即应该在微服务上生成后端文件,并且应该在网关上使用正确的“ URL路径前缀”生成相应的前端文件。 This way you can use the same jdl file for both the microservice and the gateway. 这样,您可以对微服务和网关使用相同的jdl文件。 On the microservice the keyword is ignored but on the gateway it will prevent back-end files from being generated as well as correctly setup the entity front end to call /microservice/api . 在微服务上,关键字会被忽略,但在网关上,它将阻止生成后端文件,并正确设置实体前端以调用/microservice/api

What you want is simply to generate a regular entity on your gateway, so just remove the with microservice gateway line. 您想要的只是在网关上生成一个常规实体,因此只需删除with microservice gateway行即可。

If you think that our docs should be improved in this area please submit a PR to JHipster/JHipster.github.io. 如果您认为我们的文档应该在此方面得到改进,请向JHipster / JHipster.github.io提交PR。

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

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