我用一个微服务和一个网关设置了微服务应用程序。我使用$ jhipster import-jdl books.jh命令和网关中的实体UI生成了微服务实体。网关中的JDL文件与skipServer之类的选项略有不同。我使用下面的文件为网关中的实体以及微服务中生成的实体生成UI。我正在查看其他人提出的所有文档和问题,但是找不到适合使用文档为网关中的实体使用微服务和UI生成实体的文档(需要在JDL文件中指定微服务的路径)。如果我的语法不正确,请更正我。一切进展顺利,当打开“我”实体页面并尝试保存对象时,它没有保存它。我在控制台上收到以下错误。
POST http://localhost:8080/api/addresses 404 error (not found)
图书微服务JDL文件:
entity Address
{
streetName String required,
apartmentOrHouseNumber String,
city String required,
zipcode Long required,
state String,
country String
}
entity BookCoverType
{
coverType String required
}
entity Author
{
firstName String required,
lastName String required,
middleName String,
}
entity Book
{
bookName String required,
bookTitle String required,
numberOfPages Integer required,
}
relationship OneToOne
{
//Book{bookCoverType(coverType)} to BookCoverType
Author{address(streetName)} to Address
}
relationship OneToMany
{
BookCoverType{book(bookTitle)} to Book
Book{author(firstName)} to Author
Author{book(bookTitle)} to Book
}
paginate Book with pagination
paginate Author with pagination
BookStore网关JDL文件:
entity Address
{
streetName String required,
apartmentOrHouseNumber String,
city String required,
zipcode Long required,
state String,
country String
}
entity BookCoverType
{
coverType String required
}
entity Author
{
firstName String required,
lastName String required,
middleName String,
}
entity Book
{
bookName String required,
bookTitle String required,
numberOfPages Integer required,
}
relationship OneToOne
{
//Book{bookCoverType(coverType)} to BookCoverType
Author{address(streetName)} to Address
}
relationship OneToMany
{
BookCoverType{book(bookTitle)} to Book
Book{author(firstName)} to Author
Author{book(bookTitle)} to Book
}
skipServer *
microservice * with books
paginate Book with pagination
paginate Author with pagination
JHipster版本:4.13.3
JHipster信息:
Using JHipster version installed globally
Executing jhipster:info
Options:
Just found a `.yo-rc.json` in a parent directory.
Setting the project root at: /Users/pjadda/kubernetesapps/bookstore
Welcome to the JHipster Information Sub-Generator
##### **JHipster Version(s)**
[email protected] /Users/pjadda/kubernetesapps/bookstore
└── [email protected]
##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
<details>
<summary>.yo-rc.json file</summary>
<pre>
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.bookstore"
},
"jhipsterVersion": "4.13.3",
"baseName": "bookstore",
"packageName": "com.bookstore",
"packageFolder": "com/bookstore",
"serverPort": "8080",
"authenticationType": "jwt",
"cacheProvider": "hazelcast",
"enableHibernateCache": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "mysql",
"prodDatabaseType": "mysql",
"searchEngine": "elasticsearch",
"messageBroker": false,
"serviceDiscoveryType": "eureka",
"buildTool": "maven",
"enableSocialSignIn": false,
"enableSwaggerCodegen": true,
"jwtSecretKey": "replaced-by-jhipster-info",
"clientFramework": "angularX",
"useSass": true,
"clientPackageManager": "yarn",
"applicationType": "gateway",
"testFrameworks": [],
"jhiPrefix": "jhi",
"enableTranslation": false
}
}
</pre>
</details>
##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**
<details>
<summary>JDL entity definitions</summary>
<pre>
entity Address (address) {
streetName String required,
apartmentOrHouseNumber String,
city String required,
zipcode Long required,
state String,
country String
}
entity BookCoverType (book_cover_type) {
coverType String required
}
entity Author (author) {
firstName String required,
lastName String required,
middleName String
}
entity Book (book) {
bookName String required,
bookTitle String required,
numberOfPages Integer required
}
relationship OneToOne {
Author{address(streetName)} to Address
}
relationship OneToMany {
Book{author} to Author{book},
BookCoverType{book} to Book{bookCoverType},
Author{book} to Book{author}
}
paginate Author, Book with pagination
</pre>
</details>
##### **Environment and Tools**
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
git version 2.13.1
node: v8.9.3
npm: 5.6.0
bower: 1.8.2
yarn: 1.3.2
Docker version 17.12.0-ce, build c97c6d6
docker-compose version 1.18.0, build 8dd22a9
Congratulations, JHipster execution is complete!
Address.json
{
"fluentMethods": true,
"relationships": [],
"fields": [
{
"fieldName": "streetName",
"fieldType": "String",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "apartmentOrHouseNumber",
"fieldType": "String"
},
{
"fieldName": "city",
"fieldType": "String",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "zipcode",
"fieldType": "Long",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "state",
"fieldType": "String"
},
{
"fieldName": "country",
"fieldType": "String"
}
],
"changelogDate": "20180119060434",
"entityTableName": "address",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"skipServer": true
}
浏览器和操作系统
macOS High Sierra, Chrome browser
最佳答案
JDL文档尚不清楚。您可以为此使用一个JDL文件,并在其中指定一个微服务名称。删除skipServer选项,因为JHipster会自动为您执行此操作。按照this discussion on Github。
更新的JDl文件:
entity Address
{
streetName String required,
apartmentOrHouseNumber String,
city String required,
zipcode Long required,
state String,
country String
}
entity BookCoverType
{
coverType String required
}
entity Author
{
firstName String required,
lastName String required,
middleName String,
}
entity Book
{
bookName String required,
bookTitle String required,
numberOfPages Integer required,
}
relationship OneToOne
{
//Book{bookCoverType(coverType)} to BookCoverType
Author{address(streetName)} to Address
}
relationship OneToMany
{
BookCoverType{book(bookTitle)} to Book
Book{author(firstName)} to Author
Author{book(bookTitle)} to Book
}
microservice * with books
paginate Book with pagination
paginate Author with pagination