带有 micronaut-elasticsearch 插件的 Grails

Grails with micronaut-elasticsearch plugin

我正在迁移项目表单 grails 3.0.3elasticsearch 1.7.3grails 4.0.4elasticsearch 7.13.

不幸的是,elasticsearch-groovy-plugin is not actively maintained and it seems, that the best option is to switch to micronaut-elasticsearch

为了测试这个选项,我创建了一个新的 grails 4.0.4 应用程序并添加了

compile 'io.micronaut.elasticsearch:micronaut-elasticsearch:2.3.0'

gradle.build 文件。不幸的是我收到以下错误:

| Error Failed to compile CreateFunctionalTest.groovy: Error loading service [io.micronaut.validation.validator.DefaultAnnotatedElementValidator]: Error loading BeanIntrospection for type [class io.micronaut.validation.validator.constraints.DefaultConstraintValidators]: 'void io.micronaut.core.beans.AbstractBeanIntrospection.<init>(java.lang.Class, io.micronaut.core.annotation.AnnotationMetadata, int, int)' (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.util.ServiceConfigurationError: Error loading service [io.micronaut.validation.validator.DefaultAnnotatedElementValidator]: Error loading BeanIntrospection for type [class io.micronaut.validation.validator.constraints.DefaultConstraintValidators]: 'void io.micronaut.core.beans.AbstractBeanIntrospection.<init>(java.lang.Class, io.micronaut.core.annotation.AnnotationMetadata, int, int)'
    at io.micronaut.core.io.service.DefaultServiceDefinition.lambda$load[=11=](DefaultServiceDefinition.java:71)
    at io.micronaut.core.io.service.DefaultServiceDefinition.load(DefaultServiceDefinition.java:67)
    at io.micronaut.ast.groovy.annotation.GroovyAnnotationMetadataBuilder.<init>(GroovyAnnotationMetadataBuilder.groovy:90)
    at io.micronaut.ast.groovy.utils.AstAnnotationUtils$_getAnnotationMetadata_closure1.doCall(AstAnnotationUtils.groovy:54)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at com.sun.proxy.$Proxy20.apply(Unknown Source)
    at io.micronaut.core.util.clhm.ConcurrentLinkedHashMap.lambda$compute[=11=](ConcurrentLinkedHashMap.java:721)
    at io.micronaut.core.util.clhm.ConcurrentLinkedHashMap.compute(ConcurrentLinkedHashMap.java:733)
    at io.micronaut.core.util.clhm.ConcurrentLinkedHashMap.computeIfAbsent(ConcurrentLinkedHashMap.java:710)
    at io.micronaut.ast.groovy.utils.AstAnnotationUtils.getAnnotationMetadata(AstAnnotationUtils.groovy:53)
    at io.micronaut.ast.groovy.TypeElementVisitorTransform.visit(TypeElementVisitorTransform.groovy:83)
    at org.grails.cli.profile.commands.factory.GroovyScriptCommandFactory.readCommandFile(GroovyScriptCommandFactory.groovy:50)
    at org.grails.cli.profile.commands.factory.GroovyScriptCommandFactory.readCommandFile(GroovyScriptCommandFactory.groovy)
    at org.grails.cli.profile.commands.factory.ResourceResolvingCommandFactory.findCommands(ResourceResolvingCommandFactory.groovy:44)
    at org.grails.cli.profile.commands.CommandRegistry.findCommands(CommandRegistry.groovy:86)
    at org.grails.cli.profile.commands.CommandRegistry.findCommands(CommandRegistry.groovy)
    at org.grails.cli.profile.AbstractProfile.getCommands(AbstractProfile.groovy:439)
    at org.grails.cli.profile.repository.AbstractJarProfileRepository$JarProfile.getCommands(AbstractJarProfileRepository.groovy:130)
    at org.grails.cli.profile.AbstractProfile.getCompleters(AbstractProfile.groovy:369)
    at org.grails.cli.GrailsCli.setupCompleters(GrailsCli.groovy:420)
    at org.grails.cli.GrailsCli.handleInteractiveMode(GrailsCli.groovy:402)
    at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:273)
    at org.grails.cli.GrailsCli.main(GrailsCli.groovy:159)
Caused by: io.micronaut.core.beans.exceptions.IntrospectionException: Error loading BeanIntrospection for type [class io.micronaut.validation.validator.constraints.DefaultConstraintValidators]: 'void io.micronaut.core.beans.AbstractBeanIntrospection.<init>(java.lang.Class, io.micronaut.core.annotation.AnnotationMetadata, int, int)'
    at io.micronaut.core.beans.DefaultBeanIntrospector.findIntrospection(DefaultBeanIntrospector.java:80)
    at io.micronaut.core.beans.BeanWrapper.findWrapper(BeanWrapper.java:240)
    at io.micronaut.validation.validator.constraints.DefaultConstraintValidators.<init>(DefaultConstraintValidators.java:335)
    at io.micronaut.validation.validator.constraints.DefaultConstraintValidators.<init>(DefaultConstraintValidators.java:324)
    at io.micronaut.validation.validator.DefaultAnnotatedElementValidator$LocalConstraintValidators.<init>(DefaultAnnotatedElementValidator.java:56)
    at io.micronaut.validation.validator.DefaultAnnotatedElementValidator$LocalConstraintValidators.<init>(DefaultAnnotatedElementValidator.java:56)
    at io.micronaut.validation.validator.DefaultAnnotatedElementValidator.<init>(DefaultAnnotatedElementValidator.java:49)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at io.micronaut.core.io.service.DefaultServiceDefinition.lambda$load[=11=](DefaultServiceDefinition.java:69)
    ... 24 more
Caused by: java.lang.NoSuchMethodError: 'void io.micronaut.core.beans.AbstractBeanIntrospection.<init>(java.lang.Class, io.micronaut.core.annotation.AnnotationMetadata, int, int)'
    at io.micronaut.validation.validator.constraints.$DefaultConstraintValidators$Introspection.<init>(Unknown Source)
    at io.micronaut.validation.validator.constraints.$DefaultConstraintValidators$IntrospectionRef.load(Unknown Source)
    at io.micronaut.core.beans.DefaultBeanIntrospector.lambda$findIntrospection[=11=](DefaultBeanIntrospector.java:71)
    at io.micronaut.core.beans.DefaultBeanIntrospector.findIntrospection(DefaultBeanIntrospector.java:67)
    ... 34 more
| Error Failed to compile CreateFunctionalTest.groovy: Error loading service [io.micronaut.validation.validator.DefaultAnnotatedElementValidator]: Error loading BeanIntrospection for type [class io.micronaut.validation.validator.constraints.DefaultConstraintValidators]: 'void io.micronaut.core.beans.AbstractBeanIntrospection.<init>(java.lang.Class, io.micronaut.core.annotation.AnnotationMetadata, int, int)'
| Error Error occurred running Grails CLI: null (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.NullPointerException
    at org.grails.cli.profile.commands.factory.GroovyScriptCommandFactory.createCommand(GroovyScriptCommandFactory.groovy:85)
    at org.grails.cli.profile.commands.factory.GroovyScriptCommandFactory.createCommand(GroovyScriptCommandFactory.groovy)
    at org.grails.cli.profile.commands.factory.ResourceResolvingCommandFactory.findCommands(ResourceResolvingCommandFactory.groovy:46)
    at org.grails.cli.profile.commands.CommandRegistry.findCommands(CommandRegistry.groovy:86)
    at org.grails.cli.profile.commands.CommandRegistry.findCommands(CommandRegistry.groovy)
    at org.grails.cli.profile.AbstractProfile.getCommands(AbstractProfile.groovy:439)
    at org.grails.cli.profile.repository.AbstractJarProfileRepository$JarProfile.getCommands(AbstractJarProfileRepository.groovy:130)
    at org.grails.cli.profile.AbstractProfile.getCompleters(AbstractProfile.groovy:369)
    at org.grails.cli.GrailsCli.setupCompleters(GrailsCli.groovy:420)
    at org.grails.cli.GrailsCli.handleInteractiveMode(GrailsCli.groovy:402)
    at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:273)
    at org.grails.cli.GrailsCli.main(GrailsCli.groovy:159)
| Error Error occurred running Grails CLI: null

我是不是漏掉了什么?

micronaut-elasticsearch 不是 grails-bom 的一部分。所以你必须指定一个依赖的版本。

compile 'io.micronaut.elasticsearch:micronaut-elasticsearch:2.3.0'

https://mvnrepository.com/artifact/io.micronaut.elasticsearch/micronaut-elasticsearch