Micronaut Clubs微服务运行时错误

时间:2018-12-27 02:39:09

标签: micronaut

我正在尝试将此https://github.com/alvarosanchez/micronaut-workshop micronaut车间示例与JDK 11和Micronaut 1.0.2一起运行

更新了几个依赖项,其编译正常。当我将其抛出以下错误时。

21:27:18.607 [main] ERROR io.micronaut.runtime.Micronaut - Error starting Micronaut server: Failed to inject value for parameter [objectMapper] of class: io.micronaut
.jackson.convert.ArrayNodeToArrayConverter

Path Taken: new ArrayNodeToArrayConverter([ObjectMapper objectMapper])
io.micronaut.context.exceptions.DependencyInjectionException: Failed to inject value for parameter [objectMapper] of class: io.micronaut.jackson.convert.ArrayNodeToAr
rayConverter

Path Taken: new ArrayNodeToArrayConverter([ObjectMapper objectMapper])
        at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:981)
        at io.micronaut.jackson.convert.$ArrayNodeToArrayConverterDefinition.build(Unknown Source)
        at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1329)
        at io.micronaut.context.DefaultBeanContext.addCandidateToList(DefaultBeanContext.java:2237)
        at io.micronaut.context.DefaultBeanContext.getBeansOfTypeInternal(DefaultBeanContext.java:2165)
        at io.micronaut.context.DefaultBeanContext.getBeansOfType(DefaultBeanContext.java:752)
        at io.micronaut.context.DefaultBeanContext.getBeansOfType(DefaultBeanContext.java:522)
        at io.micronaut.context.DefaultBeanContext.getBeanRegistrations(DefaultBeanContext.java:313)
        at io.micronaut.context.DefaultApplicationContext.initializeTypeConverters(DefaultApplicationContext.java:339)
        at io.micronaut.context.DefaultApplicationContext.initializeContext(DefaultApplicationContext.java:193)
        at io.micronaut.context.DefaultBeanContext.readAllBeanDefinitionClasses(DefaultBeanContext.java:2033)
        at io.micronaut.context.DefaultBeanContext.start(DefaultBeanContext.java:156)
        at io.micronaut.context.DefaultApplicationContext.start(DefaultApplicationContext.java:141)
        at io.micronaut.runtime.Micronaut.start(Micronaut.java:67)
        at io.micronaut.runtime.Micronaut.run(Micronaut.java:271)
        at io.micronaut.runtime.Micronaut.run(Micronaut.java:257)
        at io.micronaut.runtime.Micronaut$run.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:135)
        at clubs.Application.main(Application.groovy:8)
Caused by: io.micronaut.context.exceptions.BeanInstantiationException: Error instantiating bean of type  [io.micronaut.jackson.convert.ArrayNodeToArrayConverter]

Message: Multiple possible bean candidates found: [io.micronaut.jackson.ObjectMapperFactory, io.micronaut.jackson.ObjectMapperFactory]
Path Taken: new ArrayNodeToArrayConverter([ObjectMapper objectMapper])
        at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1343)

我的代码在这里https://github.com/sfgroups/micronaut-codes/tree/master/micronaut-workshop-ex02

如何解决此运行时错误?

谢谢 SR

1 个答案:

答案 0 :(得分:0)

根据https://github.com/sfgroups/micronaut-codes/blob/9013a3daeb544cbc040f42091c2ff7995385b6a4/micronaut-workshop-ex02/build.gradle#L29上的配置,您的项目正在使用Micronaut 1.0.2。

mavenBom 'io.micronaut:micronaut-bom:1.0.2'

https://github.com/sfgroups/micronaut-codes/blob/9013a3daeb544cbc040f42091c2ff7995385b6a4/micronaut-workshop-ex02/build.gradle#L56,您将获得1.0.0.RC2的{​​{1}}版本,该版本与Micronaut 1.0.2不兼容。

discovery-client

您将需要将该版本更新为1.0.2,并希望引用compile group: 'io.micronaut', name: 'discovery-client', version: '1.0.0.RC2' 而不是micronaut-discovery-client(在RC2之后更改了模块名称)。最简单的表达方式是这样的:

discovery-client

解决此问题后,您会看到项目中存在其他问题,但是以上内容解决了问题中描述的问题。

我希望有帮助。