Kotlin 项目开发最佳实践: Kotlin + Spring Boot + kts(Kotlin Script) 全栈统一前后端

Kotlin 项目开发最佳实践: Kotlin + Spring Boot + kts(Kotlin Script) 全栈统一前后端

Spring Boot + Kotlin type safe template rendering with i18n and nested template support.

Requires Spring Framework 5.x and Kotlin 1.1+.

These templates look like:

import io.spring.demo.*

"""
${include("header")}

${i18n("title")}

    ${users.joinToLine{ "
  • ${i18n("user")} ${it.firstname} ${it.lastname}
  • " }}
${include("footer")} """

To enable variable resolution in .kts files in IDEA, go to menu preferences -> Build, Execution, Deployement -> Compiler -> Kotlin Compiler and set:

  • Script templates class: kotlin.script.templates.standard.ScriptTemplateWithBindings
  • Script templates classpath: /path/to/kotlin-script-runtime.jar

This will be configured automatically in future version of IDEA Kotlin plugin.

Feel free to send pull requests to improve it!

image.png

你可能感兴趣的:(Kotlin 项目开发最佳实践: Kotlin + Spring Boot + kts(Kotlin Script) 全栈统一前后端)