【问题标题】:Unable save data into JHipster Micro Service using Gateway UI无法使用网关 UI 将数据保存到 JHipster 微服务中
【发布时间】:2018-06-28 22:05:10
【问题描述】:

我用一个微服务和一个网关设置了我的微服务应用程序。我使用 $jhipster import-jdl books.jh 命令和网关中的实体 UI 生成了微服务实体。网关中的 JDL 文件与 skipServer 等选项略有不同。我使用以下文件为网关中的实体以及在微服务中生成的实体生成 UI。我正在查看其他人提出的所有文档和问题,但我找不到合适的文档来使用微服务和 UI 为网关中的这些实体生成实体(需要在 JDL 文件中指定微服务的路径)。如果我的语法不正确,请纠正我。一切顺利,当打开 I 实体页面并尝试保存对象时,它没有保存它。我在控制台上收到以下错误。

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)**

bookstore@0.0.0 /Users/pjadda/kubernetesapps/bookstore
└── generator-jhipster@4.13.3



##### **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

【问题讨论】:

    标签: java spring spring-boot jhipster microservices


    【解决方案1】:

    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
    

    【讨论】:

      猜你喜欢
      • 2019-09-18
      • 1970-01-01
      • 2018-12-10
      • 2020-04-20
      • 2019-01-17
      • 2020-05-11
      • 2019-02-15
      • 1970-01-01
      • 2020-11-12
      相关资源
      最近更新 更多