I have Spring Boot 3.4.0 project that uses Spring Boot AOT plugin org.springframework.boot.aot so the Java runtime runs with -Dspring.aot.enabled=true. I don't use Spring GraalVM native, so it's only AOT.

I have the following Kotlin code:

@Configuration
class TelegramCommandsConfiguration(
    private val commandsBeans: List<TelegramCommand>,
    private val callbackBeans: List<TelegramCallbackHandler>,
) {

    @Bean
    fun commands(): Map<String, TelegramCommand> = commandsBeans.associateBy { it.name() } // returns 0

    @Bean
    fun callbacks(): Map<String, TelegramCallbackHandler> = callbackBeans.associateBy { it.name() } // returns 0
}

Where: * TelegramCommand is an interface * there are N beans of it, some defined with @Bean and some defined with @Component * Being on SB 3.3.6 and Spring 6.1.15 all are fetched as expected with the List access.

Spring List of bean by types autowiring in Kotlin AOT not working since 6.2.0

But since I updated SB to 3.4.0 and made no other changes to the list variables, I fetched 0 beans by the interface TelegramCommand.

Spring List of bean by types autowiring in Kotlin AOT not working since 6.2.0

I read about the recent changes in core container but I can not find a clue about what I should do now.

Is this an issue?


I tried to run w/o AOT - all good the beans of TelegramCommand are there so it's something about AOT.


Workaround, explicit access:

```kt @Bean fun commands(): Commands = Commands( applicationContext.getBeansOfType(TelegramCommand::class.java) .entries .associateBy({ it.value.name() }, { it.value }) ) ````

Comment From: sdeleuze

Could you please test again with Spring Boot 3.4.1 and if that still occur, share a reproducer as an archive attached to this issue or as a GitHub repository?

Comment From: artemptushkin

@sdeleuze indeed it's fixed today recently released Spring Boot 3.4.1! Thank you