How to create a RESTful web application in minutes with JHipster (Spring Boot + AngularJS )


JHipster is an scaffolding tool developed by Yeoman and used to develop Spring Boot + AngularJS projects. The present post intends to guide you on how to create a new web application step by step.

Installing JHipster

Before starting with our application, you must be sure that you cover the following requirements:

  • Install and configure Java 8 on your system.
  • Install Node-js from its website, this will also install npm.
  • Install Yeoman using npm install –g yo.
  • Install Bower using npm install –g bower.
  • Install Gulp using npm install –g gulp-cli.
  • Install JHipster using npm install –g generator-jhipster.

With this simple steps JHipster has been successfully installed.

Creating an application

Once you have JHipster installed in your system, follow the next steps to create your new application.

  • Create an empty directory where the project is going to be allocated.
    mkdir jhipster-example
  • Go to the new directory.
    cd jhipster-example
  • Create a new application using the following command:
    yo jhipster
  •  JHipster will ask for authorization to send anonymously a report of usage statistics, you can decide this according to your preference.
  • The type of application you want to create, for this post we will choose Monolithic application.

  • Application name:
    • raidentrance
  • Base package name:
    • com.raidentrance.jhipster
  • Authentication type:
    • HTTP Session Authentication (stateful, default Spring Security Mechanism).
  • Data Base type:
    • SQL
  • Data Base to be used in production:
    • MySQL
  • Data Base to be used in development:
    • MySQL
  • Are you planning to use a second layer of cache on Hibernate?:
    • Yes, with ehcache (local cache for a single node).
  • Building tool:
    • Maven
  • Additional Tools:
    • None
  •  Use LibSass for CSS files processing:
    • Yes
  • Internationalization Support:
    • No. (By saying yes you will have to choose a native language and then additional languages you would like to install).
  • Testing framework:
    • Gatling
  • Override .gitignore file:
    • Yes

Once you are done with the initial configuration JHipster will generate the complete application displaying the following message:

Running the application

Up to now we should have a full project ready to be configured, compiled and run. To do this, we require some additional steps:

  • Compile the project using mvn clean install.
  • Create an empty data base for the project.
  • Modify the project configurations in the file application-dev.yml located on src/main/resources/config, in this post you have to fill the DB Url, DB User and password.
  • To execute the project you can run inside your IDE the RaidentranceApp.java as Spring Boot Application or you can use the command mvn spring-boot:run

Now you will be able to open a browser and look for http://127.0.0.1:8080 to retrieve the Welcome page from JHipster containing: In the top-left corner the profile that is being used (dev) and an account tab to register new users or use an existent account.

By default JHipster will generate an admin user with password admin, once you are authenticated you should see the following screen:

This screen will contain different sections described below:

  • Entities: here you will see the entities defined for the project, at the very beginning this is going to be empty since we haven’t created anyone.
  • Account:
    • Settings: Used to modify the username, last name and e-mail.
    • Password: Used to change the current user password.
    • Sessions: Shows the active sessions.
    • Sign Out.
  • Administration:
    • User management: Will allow you to view an modify your user accounts.
    • Metrics: Shows application metrics such as the number of http requests, use of the REST web services, cache and use of datasource.
  • Health: Shows the checks defined by the application.
  • Configuration: Shows all the current configurations for the application.
  • Audits: Allows you to enable and check entity audits.
  • Logs: Used to change the log levels on the application.
  • API: Shows the web services in the application together with a brief description on how to use each one of them.

All the features showed were created following development best practices by only executing one command and completing a quick wizard.

On the next post we will explain how to create new Web Pages , the idea will be to create a complete application piece by piece and in just a couple of minutes.

Author: Alejandro Agapito Bautista

Twitter: @raidentrance

Contact:raidentrance@gmail.com

Translated By: Oscar Camacho – melchior01

Contact: adamfirstangel@hotmail.com

Anuncios

1 comentario »

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s