使用gradle+freemarker生成代码报错The following has evaluated to null or missing

双人鱼XKQ 发布于 2017/06/27 23:39
阅读 3K+
收藏 0

* What went wrong:
Execution failed for task ':generate'.
> freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
  ==> primaryKeys[0]  [in template "src/src/main/java/${root.javaPackagePath}/${moduleName}/mgt/controller/${entityName}Controller.java.ftl" a
t line 169, column 60]

  ----
  Tip: It's the final [] step that caused this error, not those before it.
  ----
  Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value li
ke myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expressi
on; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
  ----

  ----
  FTL stack trace ("~" means nesting-related):
        - Failed at: ${primaryKeys[0].name}  [in template "src/src/main/java/${root.javaPackagePath}/${moduleName}/mgt/controller/${entityName
}Controller.java.ftl" at line 169, column 58]
  ----
================================================================

primaryKeys的获取代码
 def primaryKeys = metadata.getPrimaryKeys(null, schema, tableName)


169行报错代码
    public ${entityName}Response view(@PathVariable("${primaryKeys[0].name}") final ${primaryKeys[0].type} ${primaryKeys[0].name}, Locale locale) {

加载中
0
不愿透露姓名的Mr成
不愿透露姓名的Mr成
请使用 ${(primaryKeys[0].name)!}
0
不愿透露姓名的Mr成
不愿透露姓名的Mr成
请使用 ${(primaryKeys[ 0 ].name)!}
双人鱼XKQ
双人鱼XKQ
非常感谢,这个真的帮了我很大的忙了,由于工作比较忙,忘了感谢您了。非常感谢您,太厉害 了!
返回顶部
顶部