Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create dto failed associating with authority entity #28426

Open
2 tasks done
flyliu33 opened this issue Jan 8, 2025 · 1 comment
Open
2 tasks done

create dto failed associating with authority entity #28426

flyliu33 opened this issue Jan 8, 2025 · 1 comment

Comments

@flyliu33
Copy link

flyliu33 commented Jan 8, 2025

Overview of the issue
ERROR! An error occured while running jhipster:workspaces#generateApplications
ERROR! ERROR! Error parsing file store\src\main\java\com\jhipster\demo\store\service\mapper\SysViewPermissionMapper.java: Error: Sad sad panda, parsing errors detected in line: 11, column: 1!
Expecting token of type --> EOF <-- but found --> 'import' <--!
        ->compilationUnit at 1: package com.jhipster.demo.store.service.mapper;
2:
3:
4: import java.util.Set;
5: import java.util.stream.Collectors;
6:
7: import com.jhipster.demo.store.domain.SysViewPermission;
8: import com.jhipster.demo.store.service.dto.SysViewPermissionDTO;
9:
10: import com.jhipster.demo.store.domain.Authority;
11: import com.jhipster.demo.store.service.dto.;
12:
13: import org.mapstruct.*;
14:
15: /**
16:  * Mapper for the entity {@link SysViewPermission} and its DTO {@link SysViewPermissionDTO}.
17:  */
18: @Mapper(componentModel = "spring")
19: public interface SysViewPermissionMapper extends EntityMapper<SysViewPermissionDTO, SysViewPermission> {
20:     @Mapping(target = "authorities", source = "authorities", qualifiedByName="authorityNameSet")
21:     SysViewPermissionDTO toDto(SysViewPermission s);
22:
23:     @Mapping(target = "removeAuthority", ignore = true)
24:     SysViewPermission toEntity(SysViewPermissionDTO sysViewPermissionDTO);
25:
26:     @Named("authorityName")
27:     @BeanMapping(ignoreByDefault = true)
28:     @Mapping(target = "name", source = "name")
29:      toDtoAuthorityName(Authority authority);
30:
31:
32:     @Named("authorityNameSet")
33:     default Set<> toDtoAuthorityNameSet(Set<Authority> authority) {
34:         return authority.stream().map(this:: toDtoAuthorityName).collect(Collectors.toSet());
35:     }
36: }
37:
Error: Error parsing file store\src\main\java\com\jhipster\demo\store\service\mapper\SysViewPermissionMapper.java: Error: Sad sad panda, parsing errors detected in line: 11, column: 1!
Expecting token of type --> EOF <-- but found --> 'import' <--!
        ->compilationUnit at 1: package com.jhipster.demo.store.service.mapper;
2:
3:
4: import java.util.Set;
5: import java.util.stream.Collectors;
6:
7: import com.jhipster.demo.store.domain.SysViewPermission;
8: import com.jhipster.demo.store.service.dto.SysViewPermissionDTO;
9:
10: import com.jhipster.demo.store.domain.Authority;
11: import com.jhipster.demo.store.service.dto.;
12:
13: import org.mapstruct.*;
14:
15: /**
16:  * Mapper for the entity {@link SysViewPermission} and its DTO {@link SysViewPermissionDTO}.
17:  */
18: @Mapper(componentModel = "spring")
19: public interface SysViewPermissionMapper extends EntityMapper<SysViewPermissionDTO, SysViewPermission> {
20:     @Mapping(target = "authorities", source = "authorities", qualifiedByName="authorityNameSet")
21:     SysViewPermissionDTO toDto(SysViewPermission s);
22:
23:     @Mapping(target = "removeAuthority", ignore = true)
24:     SysViewPermission toEntity(SysViewPermissionDTO sysViewPermissionDTO);
25:
26:     @Named("authorityName")
27:     @BeanMapping(ignoreByDefault = true)
28:     @Mapping(target = "name", source = "name")
29:      toDtoAuthorityName(Authority authority);
30:
31:
32:     @Named("authorityNameSet")
33:     default Set<> toDtoAuthorityNameSet(Set<Authority> authority) {
34:         return authority.stream().map(this:: toDtoAuthorityName).collect(Collectors.toSet());
35:     }
36: }
37:
    at Object.<anonymous> (file:///C:/Users/flyli/AppData/Roaming/nvm/v20.18.0/node_modules/generator-jhipster/dist/generators/bootstrap/support/java-unused-imports-transform.js:29:27)
    at async Object.<anonymous> (file:///C:/Users/flyli/AppData/Roaming/nvm/v20.18.0/node_modules/generator-jhipster/node_modules/p-transform/dist/index.js:10:5)
    at async file:///C:/Users/flyli/AppData/Roaming/nvm/v20.18.0/node_modules/generator-jhipster/node_modules/p-transform/dist/queue.js:68:28
    at async file:///C:/Users/flyli/AppData/Roaming/nvm/v20.18.0/node_modules/generator-jhipster/node_modules/p-queue/dist/index.js:187:36
JHipster info
Welcome to JHipster v8.7.3

Welcome to the JHipster Information Sub-Generator


D:\workspace\test\jhipster\ms-ecommerce-store-struct
`-- (empty)



##### **JHipster configuration not found**


<details>
<summary>.yo-rc.json file for invoice</summary>
<pre>
{
  "generator-jhipster": {
    "applicationIndex": 2,
    "applicationType": "microservice",
    "authenticationType": "jwt",
    "autoCrlf": true,
    "baseName": "invoice",
    "buildTool": "maven",
    "cacheProvider": "redis",
    "creationTimestamp": 1736329065933,
    "databaseType": "sql",
    "devDatabaseType": "mysql",
    "enableHibernateCache": true,
    "enableSwaggerCodegen": true,
    "enableTranslation": false,
    "entities": [
      "Invoice",
      "Shipment"
    ],
    "gatewayServerPort": "8080",
    "jhiPrefix": "union",
    "jhipsterVersion": "8.7.3",
    "lastLiquibaseTimestamp": 1736328965000,
    "messageBroker": "kafka",
    "monorepository": true,
    "nativeLanguage": "zh-cn",
    "packageName": "com.jhipster.demo.invoice",
    "prodDatabaseType": "mysql",
    "searchEngine": "elasticsearch",
    "serverPort": "8082",
    "serviceDiscoveryType": "consul",
    "skipClient": true,
    "skipCommitHook": true,
    "skipUserManagement": true,
    "websocket": false
  }
}
</pre>
</details>


<details>
<summary>.yo-rc.json file for product</summary>
<pre>
{
  "generator-jhipster": {
    "applicationIndex": 1,
    "applicationType": "microservice",
    "authenticationType": "jwt",
    "autoCrlf": true,
    "baseName": "product",
    "buildTool": "maven",
    "cacheProvider": "redis",
    "creationTimestamp": 1736329065870,
    "databaseType": "sql",
    "devDatabaseType": "mysql",
    "enableHibernateCache": true,
    "enableSwaggerCodegen": false,
    "enableTranslation": false,
    "entities": [
      "Product",
      "ProductCategory",
      "ProductOrder",
      "OrderItem",
      "ProductType"
    ],
    "gatewayServerPort": "8080",
    "jhiPrefix": "union",
    "jhipsterVersion": "8.7.3",
    "lastLiquibaseTimestamp": 1736329145000,
    "messageBroker": false,
    "monorepository": true,
    "nativeLanguage": "zh-cn",
    "packageName": "com.jhipster.demo.product",
    "prodDatabaseType": "mysql",
    "searchEngine": "elasticsearch",
    "serverPort": "8081",
    "serviceDiscoveryType": "consul",
    "skipClient": true,
    "skipCommitHook": true,
    "skipUserManagement": true,
    "websocket": false
  }
}
</pre>
</details>


<details>
<summary>.yo-rc.json file for store</summary>
<pre>
{
  "generator-jhipster": {
    "applicationIndex": 0,
    "applicationType": "gateway",
    "applications": {
      "invoice": {
        "applicationIndex": 2,
        "serverPort": "8082"
      },
      "notification": {
        "applicationIndex": 3,
        "serverPort": "8083"
      },
      "product": {
        "applicationIndex": 1,
        "serverPort": "8081"
      }
    },
    "authenticationType": "jwt",
    "autoCrlf": true,
    "baseName": "store",
    "buildTool": "maven",
    "cacheProvider": "no",
    "clientFramework": "vue",
    "clientTheme": "none",
    "creationTimestamp": 1736329065890,
    "databaseType": "sql",
    "devDatabaseType": "mysql",
    "devServerPort": 9060,
    "enableHibernateCache": false,
    "enableSwaggerCodegen": false,
    "enableTranslation": false,
    "entities": [
      "SysViewPermission",
      "Customer",
      "Employee",
      "Company",
      "Product",
      "ProductType",
      "ProductCategory",
      "ProductOrder",
      "ProductOrderTest",
      "OrderItem",
      "Invoice",
      "Shipment",
      "Notification"
    ],
    "jhiPrefix": "sys",
    "jhipsterVersion": "8.7.3",
    "lastLiquibaseTimestamp": 1736329625000,
    "messageBroker": false,
    "monorepository": true,
    "nativeLanguage": "zh-cn",
    "packageName": "com.jhipster.demo.store",
    "prodDatabaseType": "mysql",
    "reactive": true,
    "searchEngine": "elasticsearch",
    "serverPort": "8080",
    "serviceDiscoveryType": "consul",
    "skipCommitHook": true,
    "testFrameworks": [
      "gatling",
      "cypress"
    ],
    "websocket": false
  }
}
</pre>
</details>


<details>
<summary>.yo-rc.json file for notification</summary>
<pre>
{
  "generator-jhipster": {
    "applicationIndex": 3,
    "applicationType": "microservice",
    "authenticationType": "jwt",
    "autoCrlf": true,
    "baseName": "notification",
    "buildTool": "maven",
    "cacheProvider": "no",
    "creationTimestamp": 1736329065933,
    "databaseType": "mongodb",
    "devDatabaseType": "mongodb",
    "enableHibernateCache": false,
    "enableTranslation": false,
    "entities": [
      "Notification"
    ],
    "gatewayServerPort": "8080",
    "jhipsterVersion": "8.7.3",
    "lastLiquibaseTimestamp": 1736328905000,
    "monorepository": true,
    "packageName": "com.jhipster.demo.notification",
    "prodDatabaseType": "mongodb",
    "serverPort": "8083",
    "serviceDiscoveryType": "consul",
    "skipClient": true,
    "skipCommitHook": true,
    "skipUserManagement": true
  }
}
</pre>
</details>
Motivation for or Use Case

create the dto as usual for every entity.

Reproduce the error

microservice-ecommerce-store-4-apps.txt

  1. download the attachment, change the postfix from txt to jdl
  2. execute command jhipster jdl .\microservice-ecommerce-store-4-apps.jdl --auto-crlf in a new folder for generating a target project
  3. then error will arise.
Related issues
Suggest a Fix
JHipster Version(s)

JHipster v8.7.3

Browsers and Operating System

Edition Windows 11 Pro
Version 24H2
Installed on ‎11/‎22/‎2024
OS build 26100.2605
Experience Windows Feature Experience Pack 1000.26100.36.0

  • Tickets opened without reproduction steps or that doesn't follows the template recommendation will be closed.
  • Checking this box is mandatory (this is just to show you read everything)
Copy link
Contributor

github-actions bot commented Jan 9, 2025

Issue check: JHipster has completed the sample check

28426 Value
Entities JDL -
--- ---
Application Generation ✔️
Check Status
Frontend check
Backend check
E2E check

This check uses jhipster info or jdl output from the issue description to generate the sample.
Bug report that does not contain this information will be marked as invalid.

invoice/.yo-rc.json
{
  "generator-jhipster": {
    "applicationIndex": 2,
    "applicationType": "microservice",
    "authenticationType": "jwt",
    "autoCrlf": true,
    "baseName": "invoice",
    "buildTool": "maven",
    "cacheProvider": "redis",
    "creationTimestamp": 1736329065933,
    "databaseType": "sql",
    "devDatabaseType": "mysql",
    "enableHibernateCache": true,
    "enableSwaggerCodegen": true,
    "enableTranslation": false,
    "entities": [
      "Invoice",
      "Shipment"
    ],
    "gatewayServerPort": "8080",
    "jhiPrefix": "union",
    "jhipsterVersion": "8.7.3",
    "lastLiquibaseTimestamp": 1736328965000,
    "messageBroker": "kafka",
    "monorepository": true,
    "nativeLanguage": "zh-cn",
    "packageName": "com.jhipster.demo.invoice",
    "prodDatabaseType": "mysql",
    "searchEngine": "elasticsearch",
    "serverPort": "8082",
    "serviceDiscoveryType": "consul",
    "skipClient": true,
    "skipCommitHook": true,
    "skipUserManagement": true,
    "websocket": false
  }
}
product/.yo-rc.json
{
  "generator-jhipster": {
    "applicationIndex": 1,
    "applicationType": "microservice",
    "authenticationType": "jwt",
    "autoCrlf": true,
    "baseName": "product",
    "buildTool": "maven",
    "cacheProvider": "redis",
    "creationTimestamp": 1736329065870,
    "databaseType": "sql",
    "devDatabaseType": "mysql",
    "enableHibernateCache": true,
    "enableSwaggerCodegen": false,
    "enableTranslation": false,
    "entities": [
      "Product",
      "ProductCategory",
      "ProductOrder",
      "OrderItem",
      "ProductType"
    ],
    "gatewayServerPort": "8080",
    "jhiPrefix": "union",
    "jhipsterVersion": "8.7.3",
    "lastLiquibaseTimestamp": 1736329145000,
    "messageBroker": false,
    "monorepository": true,
    "nativeLanguage": "zh-cn",
    "packageName": "com.jhipster.demo.product",
    "prodDatabaseType": "mysql",
    "searchEngine": "elasticsearch",
    "serverPort": "8081",
    "serviceDiscoveryType": "consul",
    "skipClient": true,
    "skipCommitHook": true,
    "skipUserManagement": true,
    "websocket": false
  }
}
store/.yo-rc.json
{
  "generator-jhipster": {
    "applicationIndex": 0,
    "applicationType": "gateway",
    "applications": {
      "invoice": {
        "applicationIndex": 2,
        "serverPort": "8082"
      },
      "notification": {
        "applicationIndex": 3,
        "serverPort": "8083"
      },
      "product": {
        "applicationIndex": 1,
        "serverPort": "8081"
      }
    },
    "authenticationType": "jwt",
    "autoCrlf": true,
    "baseName": "store",
    "buildTool": "maven",
    "cacheProvider": "no",
    "clientFramework": "vue",
    "clientTheme": "none",
    "creationTimestamp": 1736329065890,
    "databaseType": "sql",
    "devDatabaseType": "mysql",
    "devServerPort": 9060,
    "enableHibernateCache": false,
    "enableSwaggerCodegen": false,
    "enableTranslation": false,
    "entities": [
      "SysViewPermission",
      "Customer",
      "Employee",
      "Company",
      "Product",
      "ProductType",
      "ProductCategory",
      "ProductOrder",
      "ProductOrderTest",
      "OrderItem",
      "Invoice",
      "Shipment",
      "Notification"
    ],
    "jhiPrefix": "sys",
    "jhipsterVersion": "8.7.3",
    "lastLiquibaseTimestamp": 1736329625000,
    "messageBroker": false,
    "monorepository": true,
    "nativeLanguage": "zh-cn",
    "packageName": "com.jhipster.demo.store",
    "prodDatabaseType": "mysql",
    "reactive": true,
    "searchEngine": "elasticsearch",
    "serverPort": "8080",
    "serviceDiscoveryType": "consul",
    "skipCommitHook": true,
    "testFrameworks": [
      "gatling",
      "cypress"
    ],
    "websocket": false
  }
}
notification/.yo-rc.json
{
  "generator-jhipster": {
    "applicationIndex": 3,
    "applicationType": "microservice",
    "authenticationType": "jwt",
    "autoCrlf": true,
    "baseName": "notification",
    "buildTool": "maven",
    "cacheProvider": "no",
    "creationTimestamp": 1736329065933,
    "databaseType": "mongodb",
    "devDatabaseType": "mongodb",
    "enableHibernateCache": false,
    "enableTranslation": false,
    "entities": [
      "Notification"
    ],
    "gatewayServerPort": "8080",
    "jhipsterVersion": "8.7.3",
    "lastLiquibaseTimestamp": 1736328905000,
    "monorepository": true,
    "packageName": "com.jhipster.demo.notification",
    "prodDatabaseType": "mongodb",
    "serverPort": "8083",
    "serviceDiscoveryType": "consul",
    "skipClient": true,
    "skipCommitHook": true,
    "skipUserManagement": true
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants