ReflectKotlinClass не найден в Spring Boot M7 с MongoDB
Если вы создаете новый проект Spring Boot на start.spring.io с модулем Web и MongoDB, добавляете любой аннотированный класс @Document и, кроме того, обновляете kotlin.version с 1.2.10 до 1.2.21, вы получаете NoClassDefFoundError:
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.0.M7:run (default-cli) on project demo: An exception occurred while running. null: InvocationTargetException: Error creating bean with name 'mongoTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'mongoTemplate' parameter 1;
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'mappingMongoConverter' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'mappingMongoConverter' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoMappingContext' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]: Invocation of init method failed;
nested exception is java.lang.NoClassDefFoundError: kotlin/reflect/jvm/internal/impl/load/kotlin/reflect/ReflectKotlinClass:
kotlin.reflect.jvm.internal.impl.load.kotlin.reflect.ReflectKotlinClass
Когда аннотированный класс @Document удаляется, приложение запускается без проблем.
Из сообщения об ошибке это выглядит так, как будто MongoDataAutoConfiguration требует ReflectKotlinClass, который не найден в пути к классам. Модуль kotlin-рефлекса находится в списке зависимостей. Требуется ли какой-либо другой модуль kotlin?
1 ответ
Похоже, что был подан отчет об ошибке, адресованный к той же проблеме: https://jira.spring.io/browse/DATACMNS-1245 В Spring-data-commons 2.0.3.RELEASE проблема больше не возникает.