* 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) {
Gradle
Apache FreeMarker
${(primaryKeys[ 0 ].name)!}这种写法相比较 ${primaryKeys[ 0 ].name}来说是不是当传值为空时,不报错了,测试有用的,就是不明白原理,大佬厉害,真的很强!!