jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.59k stars 4.03k forks source link

Asking for UserRepository which doesn't exist #11377

Closed vw98075 closed 4 years ago

vw98075 commented 4 years ago
Overview of the issue

In a microservice with an optin of memcached as the following

Yes, with Memcached (distributed cache) - Warning, when using an SQL database, this will disable the Hibernate 2nd level cache!

Reproduce the error

The CacheConfiguration, somehow, needs a UserRepository while there isn't a User entity in my JDL file. When I run the build command

gradle build

I get the following error:

 Task :compileJava
Note: Hibernate JPA 2 Static-Metamodel Generator 5.4.10.Final
/home/.../2020-spring-microservices/crm/src/main/java/com/example/microservices/crm/config/CacheConfiguration.java:3: error: cannot find symbol
import com.example.microservices.crm.repository.UserRepository;
                                               ^
  symbol:   class UserRepository
  location: package com.example.microservices.crm.repository

In the class, there are two places using the repository:

    @Bean
    public CacheFactory usersByLoginCache(JHipsterProperties jHipsterProperties) {
        return this.createCache(UserRepository.USERS_BY_LOGIN_CACHE, jHipsterProperties);
    }

    @Bean
    public CacheFactory usersByEmailCache(JHipsterProperties jHipsterProperties) {
        return this.createCache(UserRepository.USERS_BY_EMAIL_CACHE, jHipsterProperties);
    }
Related issues
Suggest a Fix
JHipster Version(s)

6.7.1

JHipster configuration

├── generator-jhipster@6.7.1 └─┬ generator-jhipster-spring-cloud-stream@1.0.0 └── generator-jhipster@6.7.1 deduped

{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.example.microservices.crm",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "6.7.1",
    "applicationType": "microservice",
    "baseName": "crm",
    "packageName": "com.example.microservices.crm",
    "packageFolder": "com/example/microservices/crm",
    "serverPort": "8081",
    "authenticationType": "uaa",
    "uaaBaseName": "uaa",
    "cacheProvider": "hazelcast",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Memory",
    "prodDatabaseType": "postgresql",
    "searchEngine": false,
    "messageBroker": "kafka",
    "serviceDiscoveryType": "eureka",
    "buildTool": "gradle",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9uLWFuZC10by1rZWVwLWluLWEtc2VjdXJlLXBsYWNl",
    "embeddableLaunchScript": false,
    "creationTimestamp": 1582515167580,
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [
      {
        "name": "generator-jhipster-vuejs2",
        "version": "1.1.12"
      },
      {
        "name": "generator-jhipster-spring-cloud-stream",
        "version": "1.0.0"
      }
    ],
    "enableTranslation": true,
    "clientPackageManager": "npm",
    "nativeLanguage": "en",
    "languages": ["en", "zh-cn"],
    "blueprints": [],
    "skipClient": true,
    "skipUserManagement": true
  }
}
Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System

Linux Mint 18.2 Sonya

mraible commented 4 years ago

AFAIK, oauth2 is the only authentication type that supports having a User in a microservice application.

SudharakaP commented 4 years ago

I've reproduced this issue. You can also use a simpler configuration such as below to reproduce this issue. If anyone has some time to look at it please go ahead as I'll be working on some other issues before coming to this. :smile:

{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.mycompany.myapp"
    },
    "jhipsterVersion": "6.7.1",
    "applicationType": "microservice",
    "baseName": "jhipster",
    "packageName": "com.mycompany.myapp",
    "packageFolder": "com/mycompany/myapp",
    "serverPort": "8081",
    "authenticationType": "jwt",
    "cacheProvider": "memcached",
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "gradle",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "NzE3YmViOTUzZGY5NjAyZmRiOGNlYTVjNWM2MzAwZmM3ZjgwNGY3YTBkMTlhMWQzYWYzODI4ZmQ5ZmVkMDRlMmVmODA5MTc2NzcxNGFmODc2MjUxYmE2NzZhZmI3ZmIyYmVkMDJlM2FkYTc5NzkyM2NiYTFjZTRmN2EwYjE0ZmE=",
    "embeddableLaunchScript": false,
    "creationTimestamp": 1582521588761,
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": false,
    "clientPackageManager": "npm",
    "blueprints": [],
    "skipClient": true,
    "skipUserManagement": true
  }
}