【问题标题】:app fails to start when sleuth and zipkin are added添加 sleuth 和 zipkin 时应用程序无法启动
【发布时间】:2017-07-13 04:08:58
【问题描述】:

我有一个要更新到 1.5.1 的 Spring Boot 应用程序。效果很好,直到我将 Sleuth 和 Zipkin 添加到类路径

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-sleuth</artifactId>
    </dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>

当这些行出现时,我得到

2017-02-22 22:33:05.331 ERROR [chathub-api,,,] 7581 --- [           main] o.s.boot.SpringApplication               : Application startup failed

java.lang.NoClassDefFoundError: org/springframework/boot/context/embedded/FilterRegistrationBean

这是我的部门。管理

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Camden.SR4</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

我尝试更改为 Dalston

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Dalston.BUILD-SNAPSHOT</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/libs-snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

但错误变得更加奇怪

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

Description:

Parameter 0 of method envInfoContributor in org.springframework.boot.actuate.autoconfigure.InfoContributorAutoConfiguration required a bean of type 'org.springframework.core.env.ConfigurableEnvironment' that could not be found.

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'traceWebFilter' defined in class path resource [org/springframework/cloud/sleuth/instrument/web/TraceWebAutoConfiguration.class]: Unsatisfied dependency expressed through method 'traceWebFilter' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'traceFilter' defined in class path resource [org/springframework/cloud/sleuth/instrument/web/TraceWebAutoConfiguration.class]: Unsatisfied dependency expressed through method 'traceFilter' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sleuthTracer' defined in class path resource [org/springframework/cloud/sleuth/autoconfig/TraceAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sleuthTracer' parameter 4; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'zipkinSpanListener' defined in class path resource [org/springframework/cloud/sleuth/zipkin/ZipkinAutoConfiguration.class]: Unsatisfied dependency expressed through method 'zipkinSpanListener' parameter 2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.core.env.Environment' available: expected at least 1 bean which qualifies as autowire candidate. Dependenc...

我错过了什么我还没有注意到的东西吗?

【问题讨论】:

    标签: spring-boot spring-cloud zipkin spring-cloud-sleuth


    【解决方案1】:

    即使我在设置项目时也遇到了这个错误。我在 Brixton.SR6 版本中使用 Spring boot 1.5.8。但是,当我访问http://projects.spring.io/spring-cloud/ 网站时,我知道了这个问题,我将我的依赖项更新为 Dalston.SR4,然后应用程序开始工作。

    【讨论】:

      【解决方案2】:

      我无法解释您使用 Dalston.BUILD-SNAPSHOT 时遇到的错误,但 Camden.SR4 的错误是因为它与 Spring Boot 1.5 不兼容。我建议升级到 Camden.SR5 which is compatible with Spring Boot 1.5

      【讨论】:

      • 对不起,同样的错误:No qualifying bean of type 'org.springframework.core.env.Environment。有趣的是,在快速入门部分的projects.spring.io/spring-cloud 上,如果我选择 Camdem.SR5,它会将 SB 版本更改为 1.4.4.RELEASE,这可能会引起一些混乱。网站过时了吗?
      猜你喜欢
      • 1970-01-01
      • 2017-08-03
      • 2017-12-16
      • 2021-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多