Getting Started With JHipster: Part I
So, you want to stay on the leading edge of technology, but feel overwhelmed by all the moving parts. You’re in luck! This is where JHipster shines.
Join the DZone community and get the full member experience.Join For Free
If you like the Ruby on Rails or Grails approach to getting an application up-and-running in a hurry, then this may be the right fit for you. jHipster aims to make setting-up an app fairly painless.
In this JHipster series we are going to take you through, first, creating a monolithic application. Secondly, we will make an app in the microservices style. Last, we’ll give you some tips and tricks.
jHipster – What Is it?
JHipster’s goal is to generate for you a complete and modern web app, unifying:
- A high-performance and robust Java stack on the server-side with Spring Boot
- A sleek, modern, mobile-first front-end with AngularJS and Bootstrap
- A powerful workflow to build your application with Yeoman, Bower, Gulp and Maven
Who’s Using It?
- Responsive web design
- HTML5 boilerplate
- Twitter Bootstrap
- Compatible with IE9+ and modern browsers
- Full internationalization support with Angular Translate
- Optional Sass support for CSS design
- Optional WebSocket support with Spring Websocket
- Spring Boot for easy application configuration
- Maven or Gradle configuration for building, testing, and running the application “development” and “production” profiles (both for Maven and Gradle)
- Spring Security
- Spring MVC REST + Jackson
- Optional WebSocket support with Spring Websocket
- Spring Data JPA + Bean Validation
- Database updates with Liquibase
- Elasticsearch support if you want to have search capabilities on top of your database
- MongoDB support if you’d rather use a document-oriented NoSQL database instead of JPA
- Cassandra support if you’d rather use a column-oriented NoSQL database instead of JPA
Production Utilities and the Like
- Monitoring with Metrics
- Caching with ehcache (local cache) or hazelcast (distributed cache)
- Optional HTTP session clustering with hazelcast
- Optimized static resources (gzip filter, HTTP cache headers)
- Log management with Logback, configurable at runtime
- Connection pooling with HikariCP for optimum performance
- Builds a standard WAR file or an executable JAR file
Installation is a Breeze
- npm install of yo, bower, gulp, generator-jhipster
- Vagrant support
- Docker support
Monolithic or Microservice
The first question JHipster will ask you is what kind of application you want to generate. You have in fact the choice between two architecture styles.
- Choose which one you want at build – Monolith or Microservice
- Maven or Gradle
- Other DB support (Oracle separate)
A “monolithic” architecture uses a single, one-size-fits-all application, which contains both the front-end AngularJS code, and the back-end Spring Boot code. A “microservices” architecture splits the front-end and the back-end, so that it’s easier for your application to scale and survive infrastructure issues.
A monolithic application is much easier to work on, so if you don’t have any specific requirements, this is the option we recommend, and our default option.
The Red Pill
If you have been building web apps for any length of time, more than likely you are all too familiar with the monolithic approach. One huge application that contains everything. This is the “red pill;” life as pretty much you are accustomed to.
The nice thing about JHipster is its ability to bundle up a ton of stuff out of the box for you. No questions about what security should I use, or what will I have to learn if I choose this “new” technology.
Let’s Do This
We will be pretty much following JHipster’s quick-start guide https://jhipster.github.io/#quick for this exercise.
- Install JHipster
npm install -g generator-jhipster
- Create a new directory and go into it
myApp && cd myApp
- Run JHipster and follow instructions on screen
- **Model your entities with JDL Studio and download the resulting
- **Generate your entities with
yo jhipster:import-jdl jhipster-jdl.jh
- * Assuming you have already installed Java, Git, Node.js, Bower, Yeoman and Gulp
- **These are optional steps
Give It a Try
yo jhipster, give it a minute…
Answer the questions
Pick what you want!!!
After question 16, go grab some coffee or take a stroll. It will take a while.
Get that drink and/or have a nice walk? When what seems like an eternity has passed, you’ll see this.
So, in my humble-of-humblest opinions, if you are dealing with Spring Boot and aren’t using STS (Spring Tool Suite), you may need to see a neurologist. It is by far the easiest way to fire up Boot apps. I digress, back to the task at hand.
In STS, add your project (import, etc). It will look something like below. If you didn’t bring in as a Maven project (or Gradle) then add the configuration via STS. You will see the “myApp” in the Boot Dashboard. Go ahead and fire it up.
In the console, you will see something like this:
Log in and play around. You are on your way to creating an Angular application with the backend using Spring Boot.
Until Next Time
Check back for Parts II and III.
Part II will focus on the blue pill, microservices, while Part III will talk about jHipster tips and tricks.
Published at DZone with permission of Matt McCandless, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.