JHipster Development Platform

repository·main·Indexed 12 days ago

https://github.com/jhipster/generator-jhipster

A 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.

Tokens
41.1K
Snippets
153
Records
231
Agent score
98%

What's inside JHipster

  1. What is the JHipster Control Center?

    main

    The 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.

  2. Manage Blueprint dependencies

    main

    The generator-jhipster package 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.
  3. Use EJS sub-templates in JHipster

    main

    JHipster 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 .ejs extension to enable editor syntax highlighting. You can include them using the <%- include(...) %> syntax.

    Example: To include field_validators.ejs and pass field and reactive variables:

    <%- include('../common/field_validators', {field, reactive}); -%>
    <%- include('../common/field_validators', {field, reactive}); -%>
  4. Understand the JHipster Kubernetes Operator concept

    main

    The 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 kubernetes or jhipster kubernetes-helm to 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.
  5. Compare traditional vs. unambiguous priority notation

    main

    JHipster 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 at default priority, 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
    }
  6. How the JHipster Control Center connects to applications

    main

    The 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:

    1. The user accesses the Control Center via a browser (default port 1337).
    2. The Control Center proxies requests to the JHipster applications.
    3. The JHipster applications respond via their /management endpoints.
    /---------\                         +---------------+
    | Browser |                   :1337 | JHipster      |
    \----+----/-------------+-----------> Control Center|
         |                  |           +----+----------+
         |                  |                | 
         |:8080             |:8081           | 
    +----v-----+      +-----v----+           | 
    | JHipster |      | JHipster |           | 
    |   App 1  |      |  App 2   |           | 
    +----------+      +----------+           | 
     :9999/management  :9999/management      | 
      ^                 ^                   | 
      |                 |                   | 
      +-----------------+--------------------+
  7. Use inclusive syntax for JDL and generator properties

    main

    Starting 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:

    1. Default Behavior: If an option is not explicitly defined by the user, the generator applies a reasonable default (e.g., if generateClient is not specified, it defaults to true).
    2. User Specification: If an option is specified, the generator respects the user's explicit choice (e.g., setting generateClient: false will 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 serviceClass instead of ambiguous skip commands).
  8. Understand JHipster generator types: Base, Feature, and Bootstrap

    main

    The 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 (like writing or prompting) 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.