Skip to content

jhipster/generator-jhipster-native

JHipster Native

JHipster blueprint, Spring Boot Native blueprint for JHipster

NPM version Generator Integration Test

Introduction

This is a JHipster blueprint based on the research done by @mraible and @joshlong in their spring-native-examples repository.

For simplicity, it provides an embedded generator-jhipster and a CLI. To learn more, see the following blog posts:

Installation

To install or update this blueprint:

npm install -g generator-jhipster-native

To build a native image, you need to install a JDK that is compatible with GraalVM. Please refer to the GraalVM Release Notes and install the appropriate JDK. Using SDKMAN simplifies the installation process.

sdk install java 21-graalce

Usage

How to Generate Code

To use this blueprint, run the below command

jhipster-native

When building a new application, we recommend enabling e2e testing with Cypress to ensure that no runtime errors occur.

? Besides Jest/Vitest, which testing frameworks would you like to use? (Press <space> to select, <a> to
 toggle all, <i> to invert selection, and <enter> to proceed)
❯◉ Cypress

For available options, you can run

jhipster-native app --help

How to Build a Native Image

To build a native image, execute the following command:

npm run native-package

After that, set up peripheral services like PostgreSQL using npm run services:up and ensure everything is ready.

Lastly, run the Native image and experience its fast startup 😊.

npm run native-start

If you've enabled e2e testing with Cypress, you can verify its operation using the following command:

npm run native-e2e

Native binary runtime errors

GraalVM uses metadata to generate AOT compilation.

A metadata is designed to support an specific version. Missing library range will be added as best bet and will fall back to latest version.

Metadata errors are only caught at runtime. It’s recommended to have Cypress e2e tests enabled to help identify issues during continuous integration.

Refer to GraalVM Reachability Metadata Repository

Pre-release

To use an unreleased version, install it using npm + git repository.

npm install -g jhipster/generator-jhipster-native
jhipster-native --skip-jhipster-dependencies

Updated (or pre-release) generator-jhipster

This blueprint embeds a compatible generator-jhipster version, but it's possible to use an updated generator-jhipster by running the jhipster cli with blueprints option instead of the builtin jhipster-native, like:

npm install -g generator-jhipster@latest
jhipster --blueprints native