【问题标题】:Use of jhipster application in microservicesjhipster 应用在​​微服务中的使用
【发布时间】:2021-02-24 09:47:00
【问题描述】:

首先,我是 Jhipster 的新手。我已经创建了 jhipster 网关(前端),没有应用程序(后端)。

我原以为这不会起作用,因为后端不存在/不工作,所有服务调用都将通过后端访问数据库。

当我尝试使用 http://localhost:8080 访问前端时,我可以看到一切正常。我不确定如何。谁能解释一下?

JHipster v6.10.5 用于此。

谢谢 希里什

JHispter 命令行的应用程序响应:

? Which *type* of application would you like to create? Microservice gateway 
? [Beta] Do you want to make it reactive with Spring WebFlux? No 
? What is the base name of your application? gateway 
? As you are running in a microservice architecture, on which port would like your server to run? It should be unique to avoid port conflicts. 8080 
? What is your default Java package name? com.btn.test 
? Which service discovery server do you want to use? JHipster Registry (uses Eureka, provides Spring Cloud Config support and monitoring dashboards) 
? Which *type* of authentication would you like to use? JWT authentication (stateless, with a token) 
? Which *type* of database would you like to use? SQL (H2, MySQL, MariaDB, PostgreSQL, Oracle, MSSQL) 
? Which *production* database would you like to use? MySQL ? Which *development* database would you like to use? MySQL 
? Do you want to use the Spring cache abstraction? Yes, with the Hazelcast implementation (distributed cache, for multiple nodes, supports rate-limiting for gateway applications) 
? Do you want to use Hibernate 2nd level cache? Yes 
? Would you like to use Maven or Gradle for building the backend? Maven 
? Which other technologies would you like to use? 
? Which *Framework* would you like to use for the client? Angular 
? Would you like to use a Bootswatch theme (https://bootswatch.com/)? Default JHipster 
? Would you like to enable internationalization support? No 
? Besides JUnit and Jest, which testing frameworks would you like to use? Gatling, Cucumber, Protractor 
? Would you like to install other generators from the JHipster Marketplace? (y/N) No

emp.jdl

/**
 * The Employee entity.
 * @author Shirish Bathe
 */
entity Employee {
    name String required unique
    dept String
}

现在我使用 http://localhost:8080 访问网关并尝试访问员工实体。我能够在表格中看到(假)数据。

因此,即使后端应用程序不存在,应用程序也可以正常工作。如何?我错过了什么吗?

【问题讨论】:

    标签: jhipster


    【解决方案1】:

    网关包含整个 UI。当您定义实体时,微服务就会发挥作用。这些不由网关管理(但 UI 是)。这张概览图很好地描述了架构:

    https://www.jhipster.tech/microservices-architecture/

    【讨论】:

    • 感谢您的快速响应。我使用以下输入创建了网关应用程序,并使用 jdl (emp.jdl) 添加了新实体。现在我可以使用localhost:8080 访问网关并尝试访问员工实体。我能够在表格中看到(假)数据。因此,即使后端应用程序不存在,应用程序也可以正常工作。如何?我错过了什么吗?您可以访问示例代码@github.com/bathe/test。我正在使用 mysql db 和 root 作为用户和密码。
    • 你能发布你的jdl吗?您可以定义创建实体的位置。网关上可能有实体。查看您的代码,员工实体是网关的一部分。请参阅此处,例如 github.com/bathe/test/blob/main/src/main/java/com/btn/test/web/…。您看到的数据是在开发配置文件中运行时通过 liquibase 迁移创建的。
    • 我的 Jdl 很简单,并作为我主要问题的一部分发布。我已经使用 jhipster 命令生成了网关,然后我使用上面的 jdl 添加了 emp 实体。您能否让我知道如何定义创建位置。我想要应用程序(后端)代码中的所有实体。
    • 看看这个例子。您定义了三个应用程序(1 个网关,2 个微服务)。每个应用程序都包含它们负责的实体。 github.com/jhipster/jdl-samples/blob/main/reactive-ms.jdl你可以在空目录下做jhipster jdl,它会为你创建三个文件夹(网关、博客微服务和商店微服务)。
    猜你喜欢
    • 2018-01-10
    • 1970-01-01
    • 2021-03-12
    • 2021-08-26
    • 1970-01-01
    • 1970-01-01
    • 2017-07-12
    • 2018-01-02
    • 2016-11-22
    相关资源
    最近更新 更多