jhipster / generator-jhipster-micronaut

Micronaut blueprint for JHipster
Apache License 2.0
99 stars 29 forks source link

JPA default entity scan fails on newly created project #388

Open vcupelloni opened 3 weeks ago

vcupelloni commented 3 weeks ago
Overview of the issue

It seems that by creating a new microservice from scratch without entities and with User entity creation disabled, it cannot then be started due to an error in JPA's automatic entity scan.

image

Creating even a single entity with jhipster generator solves all the problems and the project can run.

Reproduce the error

Install JHipster and Micronaut blueprint, configure an application (in the screenshot I used microservice/postgresql/ehcache but itried several configuration with same results) , start the project after generation is completed.

image

Suggest a Fix

I am not aware of a parameter to disable JPA's autoscan, the only way I found to start the application is to comment out in the build.gradle file the dependency to io.micronaut.data:micronaut-data-hibernate-jpa

Is it feasible that this dependency will only be added if there is at least one entity?

Project configuration
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "microservice",
    "authenticationType": "jwt",
    "backendType": "micronaut",
    "baseName": "myprojectMicroservice",
    "blueprints": [
      {
        "name": "generator-jhipster-micronaut",
        "version": "3.4.1"
      }
    ],
    "buildTool": "gradle",
    "cacheProvider": "ehcache",
    "clientFramework": "no",
    "clientTestFrameworks": null,
    "clientTheme": null,
    "creationTimestamp": 1724496465308,
    "devDatabaseType": "h2Disk",
    "enableGradleEnterprise": false,
    "enableHibernateCache": true,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "entities": [],
    "gradleEnterpriseHost": null,
    "jhipsterVersion": "8.5.0",
    "languages": [
      "it"
    ],
    "messageBroker": "no",
    "microfrontend": null,
    "microfrontends": [],
    "nativeLanguage": "it",
    "packageName": "com.mycompany.myapp",
    "prodDatabaseType": "postgresql",
    "searchEngine": "no",
    "serverPort": 8081,
    "serverTestFrameworks": [],
    "serviceDiscoveryType": "consul",
    "skipClient": true,
    "syncUserWithIdp": null,
    "testFrameworks": [
      []
    ],
    "withAdminUi": null
  }
}
Environment and Tools

openjdk version "21.0.4" 2024-07-16 OpenJDK Runtime Environment (build 21.0.4+7) OpenJDK 64-Bit Server VM (build 21.0.4+7, mixed mode, sharing)

git version 2.46.0

node: v18.19.1 npm: 10.2.4

Docker version 27.1.2, build d01f264bcc

vcupelloni commented 2 weeks ago

Does anyone know how I can inject the information about how many entities have been generated within the context so I can put a check in the build.gradle.ejs template?

The information is present in the yo-rc.json file but I don't know how to retrieve it cleanly.

Right now I am under the impression that the generator cannot be used out-of-the box or at least it generates broken code, am I wrong?