JHipster Development Platform
repository·main·Indexed 12 days ago
https://github.com/jhipster/generator-jhipsterA development platform to generate, develop, and deploy modern web applications and microservices using Spring Boot and frontend frameworks like Angular, React, or Vue. Version 9.2.0 includes sub-generators for OpenAPI, Gatling load testing, Liquibase migrations, and an upgrade tool to automate version transitions.
What's inside JHipster
- The Spring Boot sub-generator is a component of JHipster responsible for generating the Spring Boot backend application. It handles the creation of the server-side logic, including REST controllers, service layers, and data access components.
Use the Liquibase sub-generator for SQL and Neo4j
mainThe Liquibase sub-generator adds database migration support using Liquibase for SQL databases and Neo4j. It allows you to manage schema changes and data migrations through structured changelogs.Use the SQL/spring-boot:data-relational sub-generator
mainThesql/spring-boot:data-relationalsub-generator is used to add support for relational data handling within a Spring Boot application. It provides SQL-related utilities and configuration necessary for managing relational databases in a JHipster-generated Spring Boot environment.Use the JHipster app sub-generator
mainThejhipstercommand is the main entrypoint for the application sub-generator. It is a composite generator that orchestrates several other sub-generators, includingcommon,languages,server, andclient, to build a complete application.What is the JHipster Control Center?
mainThe JHipster Control Center is an external management and monitoring application designed to provide a centralized administrator UI for JHipster applications. Instead of embedding management screens within every monolith or microservice (which causes code duplication and slower builds), the Control Center connects to JHipster applications via their management API endpoints.
It is designed to work with any JHipster application type, including monoliths, gateways, back-end only microservices, and front-end only UIs. It serves both development and production environments.
Manage Blueprint dependencies
mainThe
generator-jhipsterpackage uses exact versions for all its dependencies.Warning: If your blueprint also uses exact versions, you will end up with duplicated dependencies with different versions inside
node_modules.Recommendation:
- Avoid using exact versions for dependencies in your blueprint.
- Disable auto-updates for your dependencies, as they will be updated automatically every time you regenerate the blueprint using
generate-blueprint.
Use EJS sub-templates in JHipster
mainJHipster uses EJS for templating. For complex logic, it is recommended to externalize JS fragments into sub-templates located in the same folder.
Sub-templates should use the
.ejsextension to enable editor syntax highlighting. You can include them using the<%- include(...) %>syntax.Example: To include
field_validators.ejsand passfieldandreactivevariables:<%- include('../common/field_validators', {field, reactive}); -%><%- include('../common/field_validators', {field, reactive}); -%>Understand the JHipster Kubernetes Operator concept
mainThe JHipster Kubernetes Operator is a component designed to run alongside JHipster Microservices applications in a Kubernetes cluster. It uses Kubernetes Custom Resource Definitions (CRDs) to encapsulate operational knowledge specific to JHipster, making the platform aware of JHipster-specific concepts like Gateways, Microservices, and Registries.
Key distinctions:
- Not a deployment tool: You should still use
jhipster kubernetesorjhipster kubernetes-helmto generate manifests and tools like HELM for deployment. The Operator manages applications after they are running. - Not a routing tool: It can configure routing in tools like Istio or Ingress controllers, but it does not perform the routing itself.
- Non-intrusive: It does not change the existing JHipster architecture; it sits on top of it to provide advanced lifecycle management and topology awareness.
- Not a deployment tool: You should still use
Compare traditional vs. unambiguous priority notation
mainJHipster has transitioned from Yeoman's traditional priority notation to an unambiguous API to prevent accidental task queuing.
Traditional Notation (Deprecated/Avoid): Uses standard getters like
get initializing(). Any method defined in the class that does not start with an underscore_is automatically treated as a task and queued atdefaultpriority, which can lead to unexpected execution.Unambiguous Notation (Current): Uses a constant for the getter name, where the constant value is prefixed with
#(e.g.,#initializing). This ensures that only methods explicitly returned within the priority getter are queued as tasks, while all other class methods remain ordinary members.// TRADITIONAL (Avoid) get initializing() { return { initializingTask() { this._sayHello(); } } } aTaskQueuedAtDefaultPriority() { // This is accidentally queued because it lacks a '_' prefix } // UNAMBIGUOUS (Recommended) get [INITIALIZING_PRIORITY]() { return { initializingTask() { this.sayHello(); } } } anOrdinaryClassMember() { // This is NOT queued because the priority is defined via the # prefix constant }How the JHipster Control Center connects to applications
mainThe JHipster Control Center acts as a web application that communicates with JHipster application instances through their management endpoints.
To improve security, it is recommended to expose these management endpoints on a dedicated management port (typically
9999) rather than the standard API port (e.g.,8080). This allows the management traffic to be isolated from the public-facing API traffic.Architecture Flow:
- The user accesses the Control Center via a browser (default port
1337). - The Control Center proxies requests to the JHipster applications.
- The JHipster applications respond via their
/managementendpoints.
/---------\ +---------------+ | Browser | :1337 | JHipster | \----+----/-------------+-----------> Control Center| | | +----+----------+ | | | |:8080 |:8081 | +----v-----+ +-----v----+ | | JHipster | | JHipster | | | App 1 | | App 2 | | +----------+ +----------+ | :9999/management :9999/management | ^ ^ | | | | +-----------------+--------------------+- The user accesses the Control Center via a browser (default port
Use inclusive syntax for JDL and generator properties
mainStarting from version V8, JHipster follows an inclusive syntax pattern for managing properties in the generator and JDL. This means instead of using 'skip' or 'exclude' flags (exclusive syntax), you should use positive flags that define what to include or generate.
Rules for Inclusive Options:
- Default Behavior: If an option is not explicitly defined by the user, the generator applies a reasonable default (e.g., if
generateClientis not specified, it defaults totrue). - User Specification: If an option is specified, the generator respects the user's explicit choice (e.g., setting
generateClient: falsewill prevent the frontend from being generated).
Why this is used:
- Reduces cognitive overhead by avoiding double negation (e.g.,
if (!skipClient)). - Simplifies business logic within the generator.
- Provides more expressive control over specific layers (e.g., using
service * with serviceClassinstead of ambiguousskipcommands).
- Default Behavior: If an option is not explicitly defined by the user, the generator applies a reasonable default (e.g., if
Understand JHipster generator types: Base, Feature, and Bootstrap
mainThe JHipster generator is organized into three main types of generators, each with a distinct role in the inheritance and composition chain:
- Base Generators: The core layer providing fundamental functionality. They handle tasks, priorities, context loading (e.g.,
application,entities), object injection, and provide a facade of useful methods (likewritingorprompting) for downstream generators. - Feature Generators: These extend the generator by adding specific functionalities (e.g.,
cucumber,kubernetes). They focus on adding specific capabilities to the base functionality. - Bootstrap Generators: Specialized generators used to bootstrap Feature generators by executing common tasks shared across multiple features.
- Base Generators: The core layer providing fundamental functionality. They handle tasks, priorities, context loading (e.g.,