Monday, June 27, 2022

Creating Jhipster Microservice

 First make sure to install and run Jhipster- register and start the same.

C:\STS-Workspace\jhipstermicroservice\jhipster-registry>mvnw

1
2
3
4
5
6
7
8
9
10
11
12
2022-06-27 13:05:14.330  INFO 9768 --- [  restartedMain] t.jhipster.registry.JHipsterRegistryApp  : Started JHipsterRegistryApp in 23.118 seconds (JVM running for 25.57)
2022-06-27 13:05:14.342  INFO 9768 --- [  restartedMain] t.jhipster.registry.JHipsterRegistryApp  :
----------------------------------------------------------
        Application 'jhipster-registry' is running! Access URLs:
        Local:          http://localhost:8761/
        External:       http://192.168.56.1:8761/
        Profile(s):     [composite, dev, api-docs]
----------------------------------------------------------
2022-06-27 13:05:14.343  INFO 9768 --- [  restartedMain] t.jhipster.registry.JHipsterRegistryApp  :
----------------------------------------------------------
        Config Server:  Connected to the JHipster Registry config server!
----------------------------------------------------------

Once it is started check it using below url

Now create your microservice with option given below:-
Run following command and provide the valid answer for the question to create pure SpringBoot Microservice in JHipster.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
C:\STS-Workspace\jhipsterpuremicroservice>jhipster
INFO! Using bundled JHipster
 
        ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
        ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
        ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝
  ██╗   ██║ ██╔═══██║    ██║    ██╔════╝   ╚═══██╗    ██║    ██╔═══╝   ██╔══██║
  ╚██████╔╝ ██║   ██║ ████████╗ ██║       ██████╔╝    ██║    ████████╗ ██║  ╚██╗
   ╚═════╝  ╚═╝   ╚═╝ ╚═══════╝ ╚═╝       ╚═════╝     ╚═╝    ╚═══════╝ ╚═╝   ╚═╝
                            https://www.jhipster.tech
Welcome to JHipster v7.8.1
 
Application files will be generated in folder: C:\STS-Workspace\jhipsterpuremicroservice
 _______________________________________________________________________________________________________________
 
  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
 _______________________________________________________________________________________________________________
 
WARNING! Your Node version is not LTS (Long Term Support), use it at your own risk! JHipster does not support non-LTS releases, so if you encounter a bug, please use a LTS version first.
? Which *type* of application would you like to create? Microservice application
? What is the base name of your application? jhipsterpuremicroservice
? 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.siddhu.microservice
? 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) No cache - Warning, when using an SQL database, this will disable the Hibernate 2nd level cache!
? 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? No
? Please choose the native language of the application English
? Besides JUnit and Jest, which testing frameworks would you like to use? Cypress
? Would you like to install other generators from the JHipster Marketplace? No
Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 99,999 days
        for: CN=Java Hipster, OU=Development, O=com.siddhu.microservice, L=, ST=, C=
 
KeyStore 'C:\STS-Workspace\jhipsterpuremicroservice\src\main\resources\config\tls\/keystore.p12' generated successfully.

Modify the C:\STS-Workspace\jhipsterpuremicroservice\src\main\resources\config\application-dev.yml

datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://localhost:3306/jhipsterpuremicroservice?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true
username: root
password: root

Run your microservice using this command
C:\STS-Workspace\jhipsterpuremicroservice\mvnw

Open the url and see you are able to see this screen. This indicate your core microservice with JhispterRegistry is created properly.