代码之家  ›  专栏  ›  技术社区  ›  patb23

将spring cloud sleuth添加到类路径时获取“上下文初始化”错误

  •  0
  • patb23  · 技术社区  · 6 年前

    下面提供了引用spring cloud sleuth的构建文件部分。

    dependencyManagement {
      imports {
            //where springCloudVersion = "Dalston.SR5" & springBootVersion = '1.5.9.RELEASE'
    
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
      }
    } 
    //in dependencies, added the following line
    compile 'org.springframework.cloud:spring-cloud-starter-sleuth'
    

    添加此依赖项后,应用程序无法启动,出现以下异常(根据注释添加)

    support.AbstractApplicationContext (AbstractApplicationContext.java:551) - 
    Exception encountered during context initialization - cancelling refresh attempt: 
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'misds': 
    Could not bind properties to HikariDataSource (prefix=mis.datasource, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is org.springframework.validation.BindException: org.springframework.boot.bind.RelaxedDataBinder$RelaxedBeanPropertyBindingResult: 4 errors
    Field error in object 'mis.datasource' on field 'driverClassName': rejected value [oracle.jdbc.OracleDriver]; 
    codes [methodInvocation.mis.datasource.driverClassName,methodInvocation.driverClassName,methodInvocation.java.lang.String,methodInvocation]; 
    arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [mis.datasource.driverClassName,driverClassName]; 
    arguments []; default message [driverClassName]]; default message [Property 'driverClassName' threw exception; 
    nested exception is java.lang.IllegalStateException: The configuration of the pool is sealed once started.  
    Use HikariConfigMXBean for runtime changes.]
    

    我正在使用 log4j上方的slf4j 对于日志框架和应用程序,当我删除sleuth依赖项时,应用程序运行良好。

    我注意到: '附加' 当包含spring云依赖项时,就会出现propertysources。

    env.MutablePropertySources (MutablePropertySources.java:106) - Adding PropertySource 'springCloudClientHostInfo' with lowest search precedence
    env.MutablePropertySources (MutablePropertySources.java:106) - Adding PropertySource 'defaultProperties' with lowest search precedence
    env.MutablePropertySources (MutablePropertySources.java:106) - Adding PropertySource 'Management Server' with lowest search precedence
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Marcin Grzejszczak    6 年前

    始终检查最新发布的系列是否不能解决您的问题。老实说,我真的不知道哪个问题与此问题有关:/Edgware release train与Boot兼容<2