JHipster

+ + =

JHipster is a open source framework built on Yeoman generator, used to create a Spring Boot + AngularJS project. It is 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, Grunt and Maven

Technology stack

Technology stack on the client side

Single Web page application:

With the great Yeoman development workflow:

And what if a single Web page application isn’t enough for your needs?

  • Support for the Thymeleaf template engine, to generate Web pages on the server side

Technology stack on the server side

A complete Spring application:

Ready to go into production:

  • 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

Getting started

  1. Install Java from the Oracle website.
  2. (Optional) Install a Java build tool.
  3. Install Git from git-scm.com. We recommend you also use a tool like SourceTree if you are starting with Git.
  4. Install Node.js from the Node.js website. This will also install npm, which is the node package manager we are using in the next commands.
  5. Install Yeoman: npm install -g yo
  6. Install Bower: npm install -g bower
  7. Depending on your preferences, install either Grunt (recommended) with npm install -g grunt-cli or Gulp.js with npm install -g gulp.
  8. Install JHipster: npm install -g generator-jhipster
  9. First of all, create an empty directory in which you will create your application:mkdir myapplication

    Go to that directory:

    cd myapplication/

    To generate your application, type:

    yo jhipster

    And answer the questions asked by the generator to create an application taylored to your needs. Those options are described in the next section.

    Once the application is generated, you can launch the Java server within your IDE, by running the Application class at the root of your application’s Java package.

    As it is a simple “Main” class, it is the easiest and quickest way to run and debug the application.

    If you prefer to use Maven, you can also run your application by typing:

    mvn

    (this will run our default Maven task, spring-boot:run)

     

    The application will be available on http://localhost:8080

  10. ConfigurationBy default, JHipster uses the “development” profile, so you don’t have to configure anything.

    If you want more information on the available profiles, please go the section titled “Profiles“.

    Running the application

    As a “main” Java class

    From your IDE, right-click on the “Application” class at the root of your Java package hierarchy, and run it directly. You should also be able to debug it as easily.

    The application will be available on http://localhost:8080.

  11. Using the Java server and Grunt togetherWe highly recommend you use this feature, as it allows to have live reloading of your client-side code.

    You can use Grunt to work on the client-side JavaScript application:

    grunt

    (this will run our default Grunt task, serve)

    This should open up your Web browser, with live reload enabled, on http://localhost:3000. This works thanks to BrowserSync, and you can access its administration screen on http://localhost:3001.

    This provides two very impressive features:

    • As soon as you modify one of your HTML/CSS/JavaScript file, your browser will refresh itself automatically
    • When you test your application on several different browsers or devices, all your clicks/scrolls/inputs should be automatically synchronized on all screens

    This Grunt task has a proxy to the REST endpoints on the Java server which we just launched (on http://localhost:8080/api), so it should be able to do live REST requests to the Java back-end.

    If you have generated your application with the Sass option, your templates should also be automatically compiled into CSS.

    Tips’n tricks

    • In some browsers (like Chrome), your HTML/CSS/JS resources can be cached, and hence can have some trouble getting live-reloaded. To force them to be reloaded, open up the “developer console” and select “Disable cache (while DevTools is open)”.
    • As the Grunt server proxies request to the Java server, all REST requests will fail if the Java server is down. So if your Grunt server shows a blank screen, the first thing to check is if the Java server is running at http://127.0.0.1:8080.

    If you want more information on using Grunt, please go to http://gruntjs.com.

    Using Bower to install and update JavaScript, CSS and Sass dependencies

    You can use bower to update your JavaScript, CSS and Sass dependencies:

    bower update

    Or if you want to install a new JavaScript, CSS or Sass dependency:

    bower install <package> --save

    Your JavaScript, CSS or Sass dependencies will be stored in your src/main/webapp/bower_components folder, and we believe it is a good idea to store them in your Git repository (but JHipster does not force you to do so).

    If the installed dependency contains JavaScript files they will automatically be injected into your index.html and karma.conf.js files. Likewise the CSS files will be injected into the index.html file, and the SCSS files into the main.scss.

    However this will only work if the Grunt server is running. If it is not running they will be injected next time you run grunt.

    Or, if you want to trigger the injection manually, just run:

    grunt wiredep

    If you want more information on using Bower, please go to http://bower.io. For more information on using Grunt Wiredep, please go to http://stephenplusplus.github.io/grunt-wiredep.

 

See:

 

Configuring your IDE Source: jhipster.github.io/configuring-ide-idea/

Creating an application Source: jhipster.github.io/creating-an-app/

Creating an entity Source: jhipster.github.io/creating-an-entity/

Creating a service Source: jhipster.github.io/creating-a-service/

Using DTOs Source: jhipster.github.io/using-dtos/

 

Managing relationships Source: jhipster.github.io/managing-relationships/

 

 

Website

 

  • JHipster – A hipster stack for Java developers

    Hipster stack for Java developers. Yeoman + Maven + Spring + AngularJS in one handy generator.

    Source: jhipster.github.io/presentation/