spring-attic / spring-native

Spring Native is now superseded by Spring Boot 3 official native support

Home Page:https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing reflection for ReactiveMongoTemplate

Kotlin-GDE opened this issue · comments

hi

spring boot 2.7.3, graalvm 22.1.0, spring native 0.12.1

fun createMongoTemplate() = ReactiveMongoTemplte(MongoClients.create(url, database)

class CustomRepository(private val mongo: ReactiveMongoTemplate) { ......... }

@SpringBootApplication
@TypeHint(types = [CustomRepository::class])
fun main() {
    runApplication() {
         addInitializers(beans {
                bean(::createMongoTemplate)
                bean<CustomRepository>()
        })
}    

its works fine when from jar file, however when launch native executable:

2022-08-24 14:04:28.186  WARN 17822 --- [           main] .r.c.ReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.projectlocation.authentication.repository.ProfileRepository#0': Unexpected exception during bean creation; nested exception is java.lang.ClassNotFoundException: org.springframework.data.mongodb.core.ReactiveMongoTemplate
2022-08-24 14:04:28.188 ERROR 17822 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Native reflection configuration for org.springframework.data.mongodb.core.ReactiveMongoTemplate is missing.

Action:

Native configuration for a class accessed reflectively is likely missing.
You can try to configure native hints in order to specify it explicitly.
See https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/#native-hints for more details.

spring native docs mention that support spring data mongo, so whats wrong ??