- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.8k
Closed as not planned
Closed as not planned
Copy link
Labels
status: duplicateA duplicate of another issueA duplicate of another issuetheme: aotAn issue related to Ahead-of-time processingAn issue related to Ahead-of-time processingtheme: kotlinAn issue related to Kotlin supportAn issue related to Kotlin support
Description
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:
- TelegramCommandis an interface
- there are N beans of it, some defined with @Beanand some defined with@Component
- Being on SB 3.3.6 and Spring 6.1.15 all are fetched as expected with the Listaccess.
 
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.
 
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:
@Bean
    fun commands(): Commands = Commands(
        applicationContext.getBeansOfType<TelegramCommand>(TelegramCommand::class.java)
            .entries
            .associateBy({ it.value.name() }, { it.value })
    )Metadata
Metadata
Assignees
Labels
status: duplicateA duplicate of another issueA duplicate of another issuetheme: aotAn issue related to Ahead-of-time processingAn issue related to Ahead-of-time processingtheme: kotlinAn issue related to Kotlin supportAn issue related to Kotlin support