Spring Kotlin References in @Value-annotation

Nicolay Mitropolsky

Here is the new blog post on Kotlin and Spring support in IntelliJ IDEA.
The Spring Framework supports reading values from different kinds of sources using the `@Value` annotation. Completion, reference navigation, and folding property names with their values is now supported for Kotlin in IntelliJ IDEA:

ValueFoldingYou can also use SpEl in the `@Value` annotation:ValueInSpelOn renaming of the bean properties all of the references are then properly updated:ValueAnnotationAndRenamingSo you can comfortably work with the `@Value` annotation in Spring-Kotlin projects with IntelliJ IDEA.

There are more posts about Kotlin with Spring support in IntelliJ IDEA coming. Please stay tuned!

Comments below can no longer be edited.

6 Responses to Spring Kotlin References in @Value-annotation

  1. Yaml says:

    October 10, 2018

    I use a YAML file instead of Properties file.

    The completion does not work with the YAML file, does it?

  2. zhangchuanben says:

    November 6, 2018

    The idea crash when i use spring environment.getProperty() method

  3. zhangchuanben says:

    November 6, 2018

    When use @Value or environment.getProperty() method, while property not locally but remote, the idea crash, my idea version is 20118.2.4

  4. peter lai says:

    September 16, 2019

    import org.springframework.beans.factory.annotation.Value
    import org.springframework.context.annotation.Configuration

    @Configuration
    open class databaseHandler() {

    @Value(“\${app.url}”)
    lateinit var roboopsurl: String

    fun get(): Status {
    println(“susan $roboopsurl”)

    I’ve got this, but everytime i run it, via a restcontroller in another class, i get a:
    lateinit property roboopsurl has not been initialized] with root cause

Subscribe

Subscribe for updates