Escape @Value Spring Annotation in Kotlin

If you are using Spring annotations like 
Value("${repositoryServiceUri}")
in your Kotlin code, you might get compile-time errors like these




Error:Kotlin: [Internal Error] org.jetbrains.jet.utils.KotlinFrontEndException: Exception while analyzing expression at (16,14) in /Users/alex/my/project/loxal/rest-kit/src/main/kotlin/net/loxal/soa/restkit/client/RepositoryClient.kt:
repositoryServiceUri
Error:Kotlin: Compiler terminated with exit code: 2

because the ${blub} notation is also used by Kotlin for expression and literal resolution. So just add a backslash like
Value("\${repositoryServiceUri}")
and everything is going to be alright. 

Comments

Popular posts from this blog

Apple's evaluating a new JVM

Tuning ext4 for performance with emphasis on SSD usage