Reputation: 352
I set up my micro-services application with one microservice and one gateway. I generated micro service entities using $jhipster import-jdl books.jh command and entities UI in gateway. JDL file in the gateway is slightly different with options like skipServer. I used below file to generate UI for entities in gateway, and those entities generated in microservices. I was looking at all docs and issues raised by other people, but I couldn't find proper to documentation to generate Entities using Micro Service and UI for those entities in the gateway (need to specify the path of micro service in JDL file). Correct me if my syntax is incorrect. Everything went well, when open I entity page and try to save the object, it did not save it. I got following error on console.
POST http://localhost:8080/api/addresses 404 error (not found)
Books Micro Service JDL file:
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 gateway JDL file:
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 version: 4.13.3
JHipster info:
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
}
Browsers and Operating System
macOS High Sierra, Chrome browser
Upvotes: 1
Views: 536
Reputation: 4871
JDL documentation is not clear about this. You can use one JDL file for this and specify a microservice name in it. Remove skipServer option, because JHipster automatically does it for you. Follow this discussion on Github.
Updated JDl file:
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
Upvotes: 1