(2) Jhipster quickly builds microservices

(1) Introduction and installation of Jhipster https://blog.csdn.net/weixin_46085718/article/details/130282249

Table of contents

 1. Build the registration center Jhipster registry

 2. Use Jhipster to build microservices

 3. Use Jhipster to build a gateway


1. Build the registration center Jhipster registry

Jhipster registry is a configuration center based on spring cloud. All microservice apps need to be registered here. We don't need to manually create this project, Jhipster has prepared it for us

Jhipster-registryhttps://github.com/jhipster/jhipster-registry

First create a registry folder, clone the registry code to this point, you can also install docker, and then docker can also install the registry. Here is the git clone method, because docker pull is very slow.

git clone https://github.com/jhipster/jhipster-registry.git

Import the project into IDEA to run, load the pom file, and maven dependencies.

 The running screenshot is as follows:

 The operation is successful, and you can check it on the registration center management page. The account password is admin

http://localhost:8761/

 This includes system status, details, instances registered in the registry, health status, etc.

 And can view Swagger-ui

 2. Use Jhipster to build microservices

(1) Create an empty folder, cmd to run jhipster

jhipster

The first question: Ask what type of application needs to be created, common project, gateway application, microservice application

 Other questions are as follows:

You can answer as given below, refer to

Welcome to JHipster v7.9.3

Application files will be generated in folder: G:\test\Product
 _______________________________________________________________________________________________________________

  Documentation for creating an application is at https://www.jhipster.tech/creating-an-app/
  If you find JHipster useful, consider sponsoring the project at https://opencollective.com/generator-jhipster
 _______________________________________________________________________________________________________________

? Which *type* of application would you like to create? Microservice application
? Do you want to enable *microfrontends*? No
? What is the base name of your application? Product
? Do you want to make it reactive with Spring WebFlux? No
? 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. 8081
? What is your default Java package name? com.mycompany.myapp
? 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, PostgreSQL, MySQL, MariaDB, Oracle, MSSQL)
? Which *production* database would you like to use? MySQL
? Which *development* database would you like to use? MySQL
? Which cache do you want to use? (Spring cache abstraction) Redis (distributed cache)
? 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?
? Would you like to enable internationalization support? Yes
? Please choose the native language of the application Chinese (Simplified)
? Please choose additional languages to install
? Besides JUnit and Jest, which testing frameworks would you like to use?
? Would you like to install other generators from the JHipster Marketplace? No

After the project is created, it can be imported into IDEA to run. It is necessary to modify the yml configuration file, first the database configuration, and then the registration center configuration. The same computer does not need to be modified.

 Complete project structure:

 Log in to the registration center and you can see that both services have been registered, indicating that there is no problem with the configuration.

 3. Use Jhipster to build a gateway

Create a folder gateway and use the command jhipster.

? Which *type* of application would you like to create? Gateway application
? Do you want to enable *microfrontends*? 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.mycompany.myapp
? 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, PostgreSQL, MySQL, MariaDB, Oracle, MSSQL)
? Which *production* database would you like to use? MySQL
? Which *development* database would you like to use? MySQL
? Which cache do you want to use? (Spring cache abstraction) Redis (distributed cache)
? 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? Vue
? Do you want to generate the admin UI? Yes
? Would you like to use a Bootswatch theme (https://bootswatch.com/)? Default JHipster
? Would you like to enable internationalization support? Yes
? Please choose the native language of the application Chinese (Simplified)
? Please choose additional languages to install
     info Disabling hibernate cache for cache provider no
? Besides JUnit and Jest, which testing frameworks would you like to use?
? Would you like to install other generators from the JHipster Marketplace? No

Follow the above steps to build the gateway and the creation is complete.

 Modify the relevant database configuration and registration center configuration, and you can see that the registration is successful in the registration center.

Guess you like

Origin blog.csdn.net/weixin_46085718/article/details/130285118