With ever-changing business needs in organizations, IT departments are tasked with delivering high-quality software products at a very fast pace. To meet this demand, IT departments are putting more emphasis on streamlining and automating their development process. This blog outlines how JHipster can be utilized to streamline and automate the software development process.
JHipster is an open development platform built on yeoman generator standards, which greatly simplifies the generation of monolithic applications and microservices using Spring and Angular technologies. The JHipster application provides various prompts to the users and generates an application based on the answers. The application generated by JHipster is near production-ready with support for various RDBMS, NOSQL databases, deployment tools such as Docker, AWS, and support for CI/CD using tools, such as Jenkins, Gitlab, CircleCi.
Yeoman helps you to kickstart new projects, prescribing best practices and tools to help you stay productive.
A generator is a yeoman plugin which helps to generate complete projects or some useful parts.
For more information on Yeoman and generators please visit http://yeoman.io/.
JHipster is used by IT teams as a tool for Rapid Application Development by generating application code, necessary artifacts to support automated testing, and continuous delivery of the application. The generated code is standardized across the organization.
This approach has multiple benefits to the organization:
Since JHipster is an open source project, organizations can either use it directly from the public NPM registry or get a particular version of a JHipster node module into their private registry to use.
A typical JHipster development workstation consists of Java, NodeJS, Yeoman, JHipster, and any of its submodules. JHipster is invoked by the yo
command (yo jhipster
).
While the JHipster generated code follows lots of industry standards and supports various tools, organizations still need the ability to customize JHipster in order to support their specific requirements.
Some common requirements include:
Yeoman offers ways for generators to build on common ground, so generators can use the composeWith
feature of Yeoman to invoke other generators as needed. JHipster, being a yeoman generator, can leverage this functionality to support customization.
Organizations have multiple options at their disposal to enhance JHipster:
A JHipster module is a yeoman generator, which is composed with a specific JHipster subgenerator, which has access to the common functions and variables provided by JHipster and allows you to enhance the JHipster provided functionality.
A JHipster module can be invoked using the yo
command similar to JHipster.
For more information on the JHipster modules, visit How to use JHipster modules.
The below architecture can be applied when implementing custom generators or modules.
Note: During the development phase, steps 1 and 5 are performed to do local testing before committing the code into the SCM.
JHipster saves all the configuration information based on the user's input to the prompts in the .yo-rc.json file. This file can be pre-populated with all the needed information with a particular organization's defaults so that JHipster just uses this file and builds the application.
A JSON template, such as the one below, can be used and a generator can populate the rest of the information by prompting the user before invoking the JHipster.
yoconfig.json
{
"generator-jhipster": {
"promptValues": {
"packageName": "<%= packageName %>"
},
"jhipsterVersion": "4.5.3",
"baseName": "<%= appName %>",
"packageName": "<%= packageName %>",
"packageFolder": "<%= packageFolder %>",
"serverPort": "8000",
"authenticationType": "jwt",
"hibernateCache": "no",
"clusteredHttpSession": false,
"websocket": false,
"databaseType": "<%= dbType %>",
"devDatabaseType": "<%= dbType %>",
"prodDatabaseType": "<%= prodDbType %>",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": "eureka",
"buildTool": "gradle",
"enableSocialSignIn": false,
"jwtSecretKey": "5912e0dc02b7ee8eac69cfde3acafc4b3ef8cb3e",
"enableTranslation": false,
"applicationType": "microservice",
"testFrameworks": [],
"jhiPrefix": "jhi",
"skipClient": true,
"skipUserManagement": true,
"clientPackageManager": "yarn",
"useSass": false
}
}
index.js
'use strict';
const Generator = require('yeoman-generator');
const chalk = require('chalk');
const yosay = require('yosay');
var memFs = require('mem-fs');
var editor = require('mem-fs-editor');
var store = memFs.create();
var fs = editor.create(store);
module.exports = class extends Generator {
prompting() {
return this.prompt([{
type : 'input',
name : 'appName',
message : 'What is your app\'s name ?',
default : this.appname // Default to current folder name
}, {
type : 'input',
name : 'packageName',
message : 'Provide your package name ?'
},{
type : 'input',
name : 'dbType',
message : 'Provide your db type ?'
}, {
type : 'input',
name : 'prodDbType',
message : 'Provide your production db type ?'
}]).then((answers) => {
this.props = answers;
this.props.packageFolder = answers.packageName.replace(/\./g, '/');
});
}
writing () {
this.fs.copyTpl(this.templatePath('yoconfig.json'), this.destinationPath('.yo-rc.json'),
this.props);
// Run JHipster once the configuration file is //created.
this.composeWith('jhipster');
}
};
A sample implementation of the project can be found here.
When used appropriately, JHipster can be a powerful development tool for organizations to generate, develop, and deploy applications in a consistent and cost-efficient manner.