Enterprise Java

Getting Started With jHipster, Part 1

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.

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?

jhipsterseriespart1-1

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?

fullstack

https://jhipster.github.io/companies-using-jhipster/

Overview

Client-side Stack

  • Responsive web design
  • HTML5 boilerplate
  • Twitter Bootstrap
  • AngularJS
  • Compatible with IE9+ and modern browsers
  • Full internationalization support with Angular Translate
  • Optional Sass support for CSS design
  • Optional WebSocket support with Spring Websocket

Server-side Stack

  • 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.

Monolithic path

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 yo jhipster
  • **Model your entities with JDL Studio and download the resulting jhipster-jdl.jh file
  • **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

Type in 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.

jhipsterseriespart1-91

Get that drink and/or have a nice walk? When what seems like an eternity has passed, you’ll see this.

jhipsterseriespart1-92

Boot time!!

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.

jhipsterseriespart1-93jhipsterseriespart1-94

In the console, you will see something like this:jhipsterseriespart1-95

http://127.0.0.1:8080

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 Part Two and Part Three, scheduled for October 10th and October 17th.

Part Two will focus on the blue pill, microservices, while Part Three will talk about jHipster tips and tricks.

Reference: Getting Started With jHipster, Part 1 from our JCG partner Matt McCandless at the Keyhole Software blog.

Matt McCandless

Matt McCandless is a developer based in Wichita, KS. He is married to his wife Melissa of 15 years and has 4 kids. Currently developing in BackboneJS, Matt has experience in Java, JavaScript, PL/SQL, Perl and other various languages. He spends a lot of his spare time with the kids and spending time outside, occasionally running a 5k here and there to keep himself in shape.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button