Today, I want to talk about a great open-source Java project that will help you hit the ground running when starting a new Java project: JHipster.
JHipster is a Yeoman generator that will create a modern AngularJS application with a Spring Boot backend which you can use as a starting point for your own application.

As many of you were very interested in my Modern Java web application with Spring Boot post, I decided it was finally a good time play around with JHipster since it uses everything I tried to bring show you guys in that post.

Getting started with JHipster

JHipster is a generator that will give you a great initial starting point with lots of production-ready features. When you run the Yeoman generator it will ask you a few questions about what you’d like in your project like:

  • JDK7 or JDK8
  • Maven or Gradle
  • SQL, MongoDB or Cassandra
  • HTTP Session, OAuth2 or Token based Security

After answering these questions JHipster will generate a fully working application with some great features & best practises baked into it. This basically reduces the time to set up a new project properly from a few days to a little over a minute.

Sounds awesome right? Let’s have a look. I assume you already have npm, Bower and Grunt or Gulp installed. First let’s start by installing Yeoman, and then the Yeoman JHipster generator.

npm install -g yo  
npm install -g generator-jhipster  

When this is done, you are ready to start the JHipster generator (also called scaffolding):

yo jhipster  

Generate your Java & AngularJS application with JHipster

This will trigger several questions you have to answer about the application you want to make. For every option you can find more information in the JHipster documentation. After going through the questionnaire you are ready to run your application, like any other Spring boot application: mvn spring-boot:run.

By default it will run with a development Maven profile. There is also a production profile that will do everything to optimize your application like: setting caching headers, enable GZip and run a grunt build to process all static resources and put them in your /dist folder which is then served by your Spring application.

Production ready features

Let’s have a look at what is actually running on http://localhost:8080.

JHipster welcome screen

A JHipster generated application is a production ready application that comes with quite some features you’d expect to have in production. You have out of the box monitoring support by it uses the Metrics framework. If you have configured a Graphite server in the application.yml it will even try to so the data immediately after being started with the production profile.

Monitor your application status with Metrics

You are able to change every Log appender in the application at runtime through the web interface if you are logged in as an admin. No messing around with Log4J or Logback XML files and restarting your application. There is a Audit log available which is easily extended with your own entities, so you can track who/what/when changes something in your application. There are also some health checks for the database, mail server and disk space.

Change log levels on the fly

For ease in frontend development you can run grunt serve which will open a browser window with LiveReload enabled, that will refresh your browser as soon you change any HTML/JS/CSS files. This works because of BrowserSync which is already configured for you.

This is just a short intro to all the great things JHipster sets up for you when you are ready to start a new project. You don’t have to bother with all the boilerplate and just get started with your core business right away.

When you are done being amazed with the tools we as Java developers have nowadays compared to a few years ago, I have to tell you there’s even more! If you like to have your entities generated by JHipster they will be added including validation in the frontend (AngularJS validation) all the way to the database (bean validation). You can also easily include Pagination if you use the entity generator. You can do this by running yo jhipster:entity.

Cloud ready

JHipster tries to give you a cloud ready application, that’s why it will even help you to get your application deployed in the cloud like Cloud Foundry (and Bluemix), Heroku and OpenShift (BETA).

Give it a go

I’m suprised how much features you are able to choose from while generating your boilerplate application. This project has matured quite a bit over the last year since I’ve first heard from it. I definitely will try to give it a shot next time when creating a new application, since I’ll save so much time.

Tools like this really show how great our ecosystem is, all the best bit and pieces are put together for ease of use for developers. I hope I have convinced you to take a look yourself, so you can decide just how awesome this actually is. Give it a go and let me know what you think!