Technology: JHipster is the source code generation tool for Java based applications using spring and Spring Integration frameworks and AngularJS.
It also provides the way easier way to develop new features, deploy the applications on various application server and also on Service Registry like Eureka Server for service discovery.
It majorly used for developing Micro-services using Spring Boot and angularJS.
It provides the high performance, failure tolerance, cluster based applications with spring boot and robust Java based frameworks.
It uses modern front end using angularjs, bootstrap frameworks which will work for any devices like Mobile, Tablet, and laptop of various monitor sizes.
It will support modern build tools like Maven, Gradle.
It also support workflow management systems like Yeoman, Gulp/Webpack.
Installation: JHipster is depends upon below tools/softwares.
Java, NodeJS, NodeJS plugins like Yarn, Yeoman and if we want to use angularjs 1.x version we need to install Bower and gulp plugins for NodeJS.
Major Functionalities support by JHipster:
- Generate a full stack application, with many options
- Generate CRUD entities, directly or by scaffolding
- Database migrations with Liquibase
- NoSQL databases support (Cassandra, MongoDB)
- Elasticsearch support
- Websockets support (using SockJS)
- Automatic deployment to CloudFoundry, Heroku, OpenShift
Why we use JHipser: JHipster will focuses of generating high quality code using extensive set spring technologies Spring Boot, Spring security, Spring Data(JPA).JHipster creates fully configured spring boot application with a set of predefined screen for user management, monitoring and logging.
- We need to install Java( Java 8 will be preferable version)
- Install NodeJS (download and install from https://nodejs.org/dist/v6.11.2/node-v6.11.2-x64.msi link may be depending on windows OS Type.)
- Install Yeoman NodeJS globally using npm install -g yo
- For AnularJS 1.x versions
- Install bower using install Bower: npm install -g bower
- Install Gulp: npm install -g gulp-cli (If you have previously installed a version of gulp globally, run npmrm -g gulp to make sure your old version doesn’t collide with gulp-cli)
- Install JHipsterNodeJS using npm install -g generator-jhipster globally so that jhipster command will available on path.
Creating an Application: Navigate to the folder where we want to create application and run jhipster command, it will ask various questions depending on our input parameters it will create the source code accordingly.
After creating application we can run the command mvnw (if we are using Maven) or gradlew (if we are using gradle) then application will start deploying and it will available on http://localhost:8080
It also include spring developer tools for hot deployment (whenever we saves any file it will re-deploying the application in minimal time).
If any of front end related pages are modified, browser page will auto reload using live reload server, we can start the server either using gulp (for angular 1.x version) or using yarn start. Chrome provides plugin for live reload server, using plugin we need to connect to server so that any changes occur in front end pages page will auto-refreshes.
Creating Entities on Demand: Once we have created the application, we may need some enhancements/ creating some more entities for requirement basis.
Creating entity will need:
- Database Table
- Liquibase Change set
- A JPA Entity
- Optional Mapper classes (for mapping DTO to entity classes)
- Spring Data Repository(interacting with created table)
- Spring Rest MVC controller, service (for all CRUD application)
- Angular JS router, controller, service, component
- HTML files
- Integration test so that everything works as expected
- Performance tests
We can create entity in different ways either we can use JHipster UML, which allows you to use an UML editor or JDL Studio, our online tool to create entities and relationships using our domain-specific language JDL, we can also use command line tool to create entity.
Creating entities using JDL Studio:
Navigate to https://jhipster.github.io/jdl-studio/ to create jdl file, we can specify the all entities structure and we can download jdl file.
We can run command to generate entities: jhipster import-jdl<jdl-file.jh>
Creating entities using JHipster UML: we need to install jhipster-umlJHipser plugin to use UML.
npm install -g jhipster-uml
Create anuml file using any of your favorite UML Editor, use below command to generate entity files.
Also use command line to generate entities using jhipster entity <entityName> after executing the command it will ask for various inputs like field name, type etc…
Possible Fields Types in JHipster:
- String: A Java String. Its default size depends on the underlying backend (if you use JPA, it’s 255 by default), but you can change it using the validation rules
- Integer: Java Integer type
- Long: Java Long Type
- Float: Java Float Type
- Double: Java Double Type
- BigDecimal: java.math.BigDecimal object
- LocalDate: A java.time.LocalDate object
- Instant: A java.time.Instant object
- ZonedDateTime: A java.time.ZonedDateTime object, used to represent a local date-time in a given timezone
- Boolean: A Java Boolean.
- Enumeration: A Java Enumeration object
- Blob: A Blob object, used to store some binary data.
- CLOB (long text). Images will be handled specifically on the Angular side.
Validations:Validation can be set up for each field. Depending on the field type, different validation options will be available.
Validations will be generated at HTML view using Angular JS, server side using Bean Validation API (spring @Valid annotation), and also at entity level (Hibernate/JPA (entities are automatically validated before being saved)).
Validation information will also be used to generate more precise database column metadata:
Required fields will be marked non-nullable.
Fields which have a maximum length will have the same column length.
JHipster will also provide the support for pagination, if we specify at entity creation time.
JHipster provides 4 types of paginations:
- No pagination (in that case, the back-end won’t be paginated)
- A simple pager, based on the Bootstrap pager
- A complete pagination system, based on the Bootstrap pagination component
- An infinite scroll system, based on the infinite scroll directive
JHipster provides pagination using Spring Data Pageable interface.
Internationalization using JHipser: JHipster provides labels which can be internationalized based on inputs provided. JHipster will creates a src\main\webapp\i18n folder labels, it will create a json for each entity, we can copy the json we can provides the labels for different languages.
Monitoring JHipster Applications:
For monoliths and gateways, JHipster generates several dashboards to monitor each application. Those dashboards are available at runtime, and are the easiest way to do some simple monitoring.
The metrics dashboard: The metrics dashboard uses Dropwizard metrics to give a detailed view of the application performance.
It gives metrics on:
- HTTP requests
- methods used in Spring Beans (using the @Timed annotation)
- database connection pool
The health dashboard:The health dashboard uses Spring Boot Actuator’s health endpoint to give health information on various parts of the application.
The logs dashboard:The logs dashboard allows to manage at runtime the Logback configuration of the running application. Changing the log level of a Java package is as simple as clicking on a button, which is very convenient both in development and in production.
Conclusion: JHipster the Source code generation which generate using cutting edge technologies with better code quality and it provides test coverage, and also generates the performances test case. Based on inputs to JHiptser, java development outsourcing team can easily develop production based applications which easily grow to any size, fault tolerance, etc..