Axa Assurance Maroc - Insurer Innovation Award 2024
Using JHipster for generating Angular/Spring Boot apps
1. Using JHipster 4 for generating
Angular/Spring Boot apps
Yakov Fain
Farata Systems
yfain
2. About myself
• Work for Farata Systems
• Java Champion
• Latest book:
“Angular Development with TypeScript”
3. Agenda
• Part 1
- Start a Spring Boot app that serves products
- Generate a Web client with Angular CLI
- Deploy the Angular app under Spring Boot
• Part 2
- Generate an Angular/Spring Boot app with JHipster
- Monolithic vs Microservices
- Generating entities
- Internationalization
18. What’s JHipster?
• An opinionated Yeoman generator to generate,
develop, and deploy Spring Boot + Angular projects
• Docs: https://jhipster.github.io
• 500K downloads, 7300 stars on GitHub, 340 contributors
19. Why use JHipster?
• Generates a working Angular/Spring Boot in
minutes
• Automates the manual work
• Shows best practices
• Simplifies cloud deployment
20. Getting started
• Install node.js from https://nodejs.org
• Install the Yarn package manager
npm install yarn -g
• Install the Yeoman generator
npm install yo -g
• Install the JHipster generator
npm install -g generator-jhipster
• Create a new folder and cd to it
• Run JHipster and answer the questions
jhipster
21. JHipster can generate
• A monolithic app (Angular+Java inside the WAR)
• Microservices app (Angular inside a gateway
app and Java is a separate app)
• Entities for your CRUD app
24. Running a deployed monolithic app
To serve the deployed Angular app:
./mvnw
Angular
User
Spring Boot
Java
localhost:8080
25. To serve Angular client with hot reload:
yarn start
Running a monolithic app in dev
Angular
User
Webpack
dev server
localhost:9060
Java
Spring
Boot
localhost:8080
26. Generating a WAR file
• To package the app in a prod WAR file:
./mvnw -Pprod package
• You’ll get one executable WAR and another for an app
server:
target/hello-0.0.1-SNAPSHOT.war
target/hello-0.0.1-SNAPSHOT.war.original
30. Importing entities
• Importing a model created in the JDL Studio:
yo jhipster:import-jdl ~/beers.jh
• Adding an entity interactively:
yo jhipster:entity beer
35. To generate a microservices app,
run Hipster twice
• Create two directories - one for app and one for gateway
• In app dir:
• In gateway dir:
36. To start Microservices app
Docker + Consul
• In terminal 1 (Consul on 8500):
docker-compose -f src/main/docker/consul.yml up
• In terminal 2 (backend on 8081):
./mvnw
• In terminal 3 (gateway on 8080)
./mvnw
If you specified a DB during a microservice generation,
start it using docker-compose