JHipster 4 is an open-source code generator that allows you to automate generation and configuration of the Web project that uses the latest version of Angular on the front and Spring framework on the back. Over the next year, Angular/Spring combination will become a valuable addition to the skill set of any enterprise Java developer. In this presentation, you’ll see how to jump-start a Web project with JHipster.
4. Agenda
• Part 1
- Create a Spring Boot REST service
- Create 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
5. What’s Spring Boot?
An opinionated framework that generates
pre-configured bootable Java/Spring projects
https://start.spring.io
6. Our Spring Boot Controller
@RestController
@RequestMapping("/api")
public class ProductController {
Product products[] = new Product[3];
ProductController(){
products[0] = new Product(0,"First product", 59.99);
products[1] = new Product(1,"Second product", 12.50);
products[2] = new Product(2,"Third product", 14.40);
}
@RequestMapping(value="products",
method = RequestMethod.GET,
produces= MediaType.APPLICATION_JSON_VALUE)
public Product[] getProducts(){
return products;
}
}
7. Demo
• Create a new Spring Boot App called server
• Declare a REST endpoint for products
18. What’s JHipster?
• An opinionated Yeoman generator to generate,
develop, and deploy Spring Boot + Angular projects
• Docs: https://jhipster.github.io
• 500K downloads, 7K stars on GitHub, 330 contributors
19. JHipster pros
• Generates a working Angular/Spring Boot in minutes
• Automates the manual work
• Shows best practices
• Simplifies cloud deployment
20. JHipster cons
• You have to be a full stack developer to understand the tooling
• The generated app may have more features than you need
21. Getting started
• Download and 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
22. JHipster can generate
• A monolithic app (Angular inside the WAR)
• Microservices app (Angular outside the WAR)
25. Running the app
• Spring Boot app with the deployed Angular app:
./mvnw
http://localhost:8080
• Webpack server for the client and Spring Boot as REST API:
yarn start
http://localhost:4200
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
31. Adding entities with JDL-Studio
1.Define
2.Download
to a file
A sample diagram from https://gist.github.com/mraible
32. Importing entities
• Importing a model created in the JDL studio:
yo jhipster:import-jdl ~/Downloads/jhipster-blog.jh
• Adding an entity interactively:
yo jhipster:entity blog