JHipster如何控制整个微服务的生成?或者如何正确地使用JDL将生成的实体放入正确的micorservice文件夹中
我正在尝试用JHipster制作一个微服务应用程序的原型,并且我已经尝试收集所有我能够收集的信息,以便正确地完成它,但是还不完全清楚如何组合一个JDL,以便在正确的服务中生成正确的实体 我期望的是目录布局如下:JHipster如何控制整个微服务的生成?或者如何正确地使用JDL将生成的实体放入正确的micorservice文件夹中,jhipster,jdl,Jhipster,Jdl,我正在尝试用JHipster制作一个微服务应用程序的原型,并且我已经尝试收集所有我能够收集的信息,以便正确地完成它,但是还不完全清楚如何组合一个JDL,以便在正确的服务中生成正确的实体 我期望的是目录布局如下: /.. gateway <- Ideal would be to have only fronted code invoice <- Invoice CRUD code with corresponding ms (with below JDL it is empty)
/..
gateway <- Ideal would be to have only fronted code
invoice <- Invoice CRUD code with corresponding ms (with below JDL it is empty)
order <- Order CRUD code with corresponding ms
usage <- Usage CRUD code with corresponding ms (with below JDL it is empty)
application {
config {
baseName gateway,
applicationType gateway,
packageName com.org.myApp.sales,
serviceDiscoveryType eureka,
searchEngine elasticsearch,
authenticationType oauth2,
prodDatabaseType postgresql,
cacheProvider hazelcast,
buildTool gradle,
clientFramework react,
testFrameworks [protractor]
}
entities *
}
application {
config {
baseName invoice,
applicationType microservice,
packageName com.org.myApp.invoice,
serviceDiscoveryType eureka,
searchEngine elasticsearch,
authenticationType oauth2,
prodDatabaseType postgresql,
devDatabaseType postgresql,
buildTool gradle,
serverPort 8081,
skipUserManagement true
}
entities Invoice, Product
}
application {
config {
baseName usage,
applicationType microservice,
packageName com.org.myApp.usage,
serviceDiscoveryType eureka,
searchEngine elasticsearch,
authenticationType oauth2,
prodDatabaseType postgresql,
devDatabaseType postgresql,
cacheProvider no,
enableHibernateCache false,
buildTool gradle,
serverPort 8082,
skipUserManagement true
}
entities Usage
}
application {
config {
baseName order,
applicationType microservice,
packageName com.org.myApp.order,
serviceDiscoveryType eureka,
searchEngine elasticsearch,
authenticationType oauth2,
prodDatabaseType postgresql,
devDatabaseType postgresql,
buildTool gradle,
serverPort 8083,
skipUserManagement true
}
entities ProductOrder, OrderItem, ProductCategory, Product
}
entity Product {
name String required
description String
price BigDecimal required min(0)
size Size required
image ImageBlob
}
enum Size {
S, M, L, XL, XXL
}
entity ProductCategory {
name String required
description String
}
entity Customer {
firstName String required
lastName String required
gender Gender required
email String required pattern(/^[^@\s]+@[^@\s]+\.[^@\s]+$/)
phone String required
addressLine1 String required
addressLine2 String
city String required
country String required
}
enum Gender {
MALE, FEMALE, OTHER
}
entity ProductOrder {
placedDate Instant required
status OrderStatus required
code String required
invoiceId Long
}
enum OrderStatus {
COMPLETED, PENDING, CANCELLED
}
entity OrderItem {
quantity Integer required min(0)
totalPrice BigDecimal required min(0)
status OrderItemStatus required
}
enum OrderItemStatus {
AVAILABLE, OUT_OF_STOCK, BACK_ORDER
}
relationship OneToOne {
Customer{user(login) required} to User
}
relationship ManyToOne {
OrderItem{product(name) required} to Product
}
relationship OneToMany {
ProductOrder{orderItem} to OrderItem{order(code) required} ,
ProductCategory{product} to Product{productCategory(name)}
}
service Product, ProductCategory, Customer, ProductOrder, OrderItem with serviceClass
paginate Product, Customer, ProductOrder, OrderItem with pagination
/* Entities for Invoice microservice */
entity Invoice {
code String required
date Instant required
details String
status InvoiceStatus required
paymentMethod PaymentMethod required
paymentDate Instant required
paymentAmount BigDecimal required
}
enum InvoiceStatus {
PAID, ISSUED, CANCELLED
}
enum PaymentMethod {
CREDIT_CARD, CASH_ON_DELIVERY, PAYPAL
}
entity Usage {
date Instant required
details String
sentDate Instant required
userId Long required
productId Long required
}
microservice Invoice with invoice
microservice Usage with usage
microservice Product, ProductCategory, ProductOrder, OrderItem with order
dto * with mapstruct
paginate Invoice with pagination
环境:
##### **Environment and Tools**
JHipster version: v6.6.0
java version "11.0.5" 2019-10-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.5+10-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.5+10-LTS, mixed mode)
node: v12.14.0
npm: 6.13.4
yeoman: 3.1.1
INFO! Congratulations, JHipster execution is complete!
下面是我的问题:
1。究竟是什么控制实体的生成位置?
application {
config {
baseName gateway,
applicationType gateway,
packageName com.org.myApp.sales,
serviceDiscoveryType eureka,
searchEngine elasticsearch,
authenticationType oauth2,
prodDatabaseType postgresql,
cacheProvider hazelcast,
buildTool gradle,
clientFramework react,
testFrameworks [protractor]
}
entities * <-- What if all entities associated to a different service not to the gateway? (actually when I tried I ended up with an empty folder for gateway)
}
应用程序{
配置{
baseName网关,
应用类型网关,
packageName com.org.myApp.sales,
serviceDiscoveryType eureka,
搜索引擎elasticsearch,
authenticationType oauth2,
prodDatabaseType postgresql,
哈泽尔卡斯特酒店,
建筑工具gradle,
clientframeworkreact,
测试框架[量角器]
}
实体*
从后端的角度来看,实体不会在网关中生成,只生成这些实体的前端代码
网关使用它来路由到正确的微服务
来自不同微服务的实体之间不可能存在任何关系,因为它们位于不同的数据库中
1.这也是我的理解,但如果我将所有实体与某个ms关联,并给出网关实体*我将在一个空目录中生成网关,这让我感到困惑。同时,如果我将至少一个实体分离,我在网关中有代码,但它也有di的备份代码2.很清楚,但是应用程序部分中的etities部分和“microservice with”和她一起工作?我无法用你的JDL文件重现你的问题,我将它保存为apps.JDL
,然后运行jhipster import JDL apps.JDL
在一个空目录中,我不得不更改包名,因为myApp
不是一个有效的包,但随后生成的一切都很好。我对我的家庭笔记本也做了同样的操作它工作得很好。(Ubuntu)所以这似乎是某种环境/防病毒/windows策略问题。在我的合作笔记本上,它根本不确定没有生成什么服务。(windows 10,McAfee)不幸的是,没有任何错误消息。