错误:ERROR!复制模板src / main / java / package / domain / Entity.java.ejs失败

时间:2018-08-31 00:41:14

标签: jhipster

我创建了一个 hotelContactInfo.json 文件,并且我正在尝试使用JHipster生成代码:

{
    "fluentMethods": true,
    "relationships": [
        {
            "relationshipName": "hotel",
            "otherEntityName": "hotel",
            "relationshipType": "one-to-one",
            "otherEntityField": "id",
            "ownerSide": true,
            "otherEntityRelationshipName": "hotelContactInfo"
        }
    ],
    "fields": [
        {
            "fieldName": "ownerName",
            "fieldType": "String",
            "fieldValidateRules": [
                "required"
            ]
        },
        {
            "fieldName": "emails",
            "fieldType": "String[]",
            "fieldValidateRules": [
                "required"
            ]
        },
        {
            "fieldName": "mobiles",
            "fieldType": "String[]",
            "fieldValidateRules": [
                "required"
            ]
        },
        {
            "fieldName": "deskInfo",
            "fieldType": "String"
        },
        {
            "fieldName": "address",
            "fieldType": "String",
            "fieldValidateRules": [
                "required"
            ]
        },
        {
            "fieldName": "website",
            "fieldType": "String"
        },
        {
            "fieldName": "createdBy",
            "fieldType": "String",
            "fieldValidateRules": [
                "required"
            ]
        },
        {
            "fieldName": "createdDate",
            "fieldType": "LocalDate",
            "fieldValidateRules": [
                "required"
            ]
        },
        {
            "fieldName": "modifiedBy",
            "fieldType": "String"
        },
        {
            "fieldName": "modifiedDate",
            "fieldType": "LocalDate"
        }
    ],
    "changelogDate": "20180822085850",
    "dto": "no",
    "service": "serviceImpl",
    "entityTableName": "hotel_contact_info",
    "pagination": "infinite-scroll",
    "microserviceName": "hcm",
    "searchEngine": "elasticsearch",
    "enableEntityAudit": false
}

JHipster实体 HotelContactInfo :在生成代码时:

Using JHipster version installed locally in current project's node_modules
Executing jhipster:entity HotelContactInfo
Options: 

Found the .jhipster/HotelContactInfo.json configuration file, entity can be automatically generated!


The entity HotelContactInfo is being updated.

? Do you want to update the entity? This will replace the existing files for this entity, all your custom code will be overwritten Yes, re generate the entity
WARNING! jpaMetamodelFiltering is missing in .jhipster/HotelContactInfo.json, using 'no' as fallback
events.js:183
      throw er; // Unhandled 'error' event

`ERROR! 

Copying template src/main/java/package/domain/Entity.java.ejs failed. [TypeError: /Users/ramanujkumar/rt/rtservices/hcm/node_modules/generator-jhipster/generators/entity-`: 
server/templates/src/main/java/package/domain/Entity.java.ejs:24

    22| let importJsonIgnoreProperties = false;
    23| let importSet = false;
 >> 24| const uniqueEnums = {}; %><%- include imports -%>
    25| 
    26| <%_ if (databaseType === 'cassandra') { _%>
    27| import org.springframework.data.annotation.Id;

/Users/ramanujkumar/rt/rtservices/hcm/node_modules/generator-jhipster/generators/entity-server/templates/src/main/java/package/domain/imports.ejs:20
    18| -%>
    19| <%#    Checks which imports are needed -%>
 >> 20| <%
    21| 
    22| for (idx in relationships) {
    23|     if (typeof relationships[idx].javadoc != 'undefined') {

Cannot read property 'length' of undefined]
    at Environment.error (/Users/ramanujkumar/rt/rtservices/hcm/node_modules/yeoman-environment/lib/environment.js:157:40)
    at module.exports.error (/Users/ramanujkumar/rt/rtservices/hcm/node_modules/generator-jhipster/generators/generator-base.js:1978:18)
    at ejs.renderFile (/Users/ramanujkumar/rt/rtservices/hcm/node_modules/generator-jhipster/generators/utils.js:197:23)
    at tryHandleCache 

(/Users/ramanujkumar/rt/rtservices/hcm/node_modules/ejs/lib/ejs.js:254:14)
    at Object.exports.renderFile (/Users/ramanujkumar/rt/rtservices/hcm/node_modules/ejs/lib/ejs.js:482:10)
    at Object.renderContent (/Users/ramanujkumar/rt/rtservices/hcm/node_modules/generator-jhipster/generators/utils.js:193:9)
    at module.exports.template (/Users/ramanujkumar/rt/rtservices/hcm/node_modules/generator-jhipster/generators/generator-base-private.js:636:23)
    at blockTemplate.templates.forEach (/Users/ramanujkumar/rt/rtservices/hcm/node_modules/generator-jhipster/generators/generator-base.js:2326:42)
    at Array.forEach (<anonymous>)
    at module.exports.writeFilesToDisk (/Users/ramanujkumar/rt/rtservices/hcm/node_modules/generator-jhipster/generators/generator-base.js:2291:45)

1 个答案:

答案 0 :(得分:1)

您是说您是手动创建或编辑了hotelContactInfo.json文件吗?

您应该通过导入JDL文件或回答实体生成器的问题来创建/更新实体,因为这是检查语法的方式。通过直接编辑json文件,您将自行承担绕过此阶段的责任。

在这里,我怀疑"fieldType": "String[]"无效,因为它不是type supported by JHipster