https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#beans-autowired-annotation-primary

kotlin to

@Configuration
open class MovieConfiguration {

    @Bean
    @Primary
    open fun firstMovieCatalog(): MovieCatalog { ... }

    @Bean
    open fun secondMovieCatalog(): MovieCatalog { ... }

    // ...
}

Comment From: maxbiu

same question https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#beans-generics-as-qualifiers

....

Comment From: sbrannen

Good catch.

The assumption in the reference manual is that the user has set up the kotlin-spring plugin (see https://kotlinlang.org/docs/all-open-plugin.html#spring-support).

However, I don't believe that plugin is mentioned anywhere in the reference manual. Thus those examples will not work "as is".

So, let's add open where necessary in the reference manual and add a TIP pointing to the kotlin-plugin and mentioning that Kotlin projects created using start.spring.io will automatically have that plugin configured.

@SchroedingersGitHub, would you like to submit a PR to address this?

Comment From: sbrannen

So, let's add open where necessary in the reference manual and add a TIP pointing to the kotlin-plugin and mentioning that Kotlin projects created using start.spring.io will automatically have that plugin configured.

Or rather... let's not add open and instead

  • add a new section about the kotlin-spring plugin to the Kotlin section of the reference manual
  • for all affected examples, add a note that open would be necessary if you do not use the kotlin-spring plugin and point to the new section (see previous action item)

Side note: the kotlin-spring plugin is in fact mentioned in Spring Boot's Kotlin documentation and in the Spring Boot Kotlin tutorial, but it takes several clicks to find that information (and you have to know that there is a dedicated Kotlin section in the Spring Framework reference manual).

Comment From: maxbiu

@sbrannen Thank you! Okay

Comment From: snicoll

@SchroedingersGitHub please don't close the issue. There is still work to do.

Comment From: sdeleuze

FWIW using open is not idiomatic at all in Spring + Kotlin, so I would indeed favor a documentation refinement where we clarify the prerequisites like using kotlin-spring plugin for related samples (could be a comment in the Kotlin code).

Comment From: sdeleuze

I think this is properly documented here.