首页 > 解决方案 > Beans 和 RabbitTemplate/ RabbitHealth 的 TomcatStarter 错误

问题描述

我收到这样一个问题,这使我的 gradle 应用程序无法启动:

2018-06-12 14:34:21,995 ERROR org.springframework.boot.web.embedded.tomcat.TomcatStarter [localhost-startStop-1] [] [application] Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthEndpoint]: Factory method 'healthEndpoint' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.amqp.RabbitHealthIndicatorAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rabbitConfig' defined in file [C:\dev\workspace\domain\application\build\classes\java\main\pl\net\cmp\domain\application\config\RabbitConfig.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'domain.application-pl.net.cmp.domain.application.config.applicationProperties': Could not bind properties to 'applicationProperties' : prefix=domain.application, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'domain.application' to pl.net.cmp.domain.application.config.applicationProperties

我的属性似乎没问题(我制作了一个配置文件,将 yaml 映射到 java 类) 1-1.

我也有:

@Bean
public RabbitTemplate rabbitTemplate() {
    log.info("Initializing rabbitTemplate");
    return new RabbitTemplate(cachingConnectionFactory());
}

我正在为 gradle 使用最新版本的 amqp 依赖项:

compile group: 'org.springframework.boot', name: 'spring-boot-starter-amqp', version: '2.0.2.RELEASE'

我完全不知道从哪里开始出现这样的问题。你遇到过类似的事情吗?

编辑:我想我粘贴的代码与问题无关 - 但我不确定......我完全不知道。

标签: javaspring-bootgradlerabbitmq

解决方案


固定的。当你有这样的沟通时,你应该

  1. 实现spring-rabbit依赖
  2. 根据 RabbitProperties 类更改您的属性文件以建立与 RabbitMQ 的连接
  3. 创建适当的 java 类来启动 Rabbit Queues 和其他。

推荐阅读