beiken7818 2023-04-11 17:44 采纳率: 0%
浏览 16

SpringCloudConfig客户端配置数据源报错

SpringCloudConfig客户端远程配置文件配置数据源,启动客户端时日志输出

Fetching config from server at : http://192.168.1.5:7009/
2023-04-11 16:48:07.886  INFO 3452 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=base, profiles=[cksdev], label=master, version=216ba1b51abd8cf89d0ba541ebe3cc985ebee726, state=null
2023-04-11 16:48:07.886  INFO 3452 --- [           main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='configClient'}, MapPropertySource {name='https://gitee.com/timepostoffice/config-repo.git/base-cksev.yml'}]}
2023-04-11 16:48:07.911  INFO 3452 --- [           main] com.backbone.SrmBaseDataApplication      : No active profile set, falling back to default profiles: default

然后报错

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

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class


其中MapPropertySource 中的的git地址直接访问会404,报这个是没有读取到远程配置文件吗?

git上的yml配置文件:

server:
  port: 8083
  tomcat:
    uri-encoding: UTF-8
    #等待队列的长度
    accept-count: 1000
    #最大可被连接数
    max-connections: 10000
    #最大工作线程数
    max-threads: 2000
    #最小工作线程数
    min-spare-threads: 10
  max-http-header-size: 102400
spring:
  application:
    name: base
  # 通过bus消息总线组件连接到 MQ 服务
  rabbitmq: # 通过bus消息总线组件连接到 MQ 服务
    host: x.xxx.xx.xx
    port: 5000
    username: xxx
    password: xxx
  http:
    encoding:
      charset: UTF-8
      enabled: true
      force: true
  sleuth:
    web:
      client:
        enabled: true
    sampler:
      probability: 1.0 # 将采样比例设置为 1.0,也就是全部都需要。默认是 0.1
    zipkin:
      base-url: http://localhost:9411/ # 指定了 Zipkin 服务器的地址
  datasource:
    basedata:
      jdbc-url: jdbc:mysql://xxx.xx.xxx.xx:xxxx/keshun_base_test?useSSL=false&useUnicode=true&characterEncodeing=utf-8&autoReconnect=true
      username: xxx
      password: xxx
      driverClassName: com.mysql.jdbc.Driver
      # 下面为连接池的补充设置,应用到上面所有数据源中
      # 初始化大小,最小,最大
      hikari:
        minimum-idle: 100
        maximum-pool-size: 500
        idle-timeout: 30000
        max-lifetime: 180000
        # connection-timeout: 5000
        connection-test-query: select 1
        connection-init-sql: select 2
        #多少毫秒检测一次连接泄露.
        leak-detection-threshold: 1000
        test-on-borrow: true
        test-on-connect: true
        test-on-return: true
        test-while-idle: true
        #指定空闲连接检查、废弃连接清理、空闲连接池大小调整之间的操作时间间隔
        time-between-eviction-runs-millis: 10000
        #是否对连接进行包装,防止连接关闭之后被使用.
        use-disposable-connection-facade: true
        validation-interval: 10000
        alidation-query: select 3
        validation-query-timeout: 5000
        #设定连接校验的超时时间,当使用Hikari connection pool时指定
        alidation-timeout: 5000
  jpa:
    properties:
      hibernate:
        show_sql: false
        format_sql: true
        enable_lazy_load_no_trans: true
  #spring boot 静态资源路径配置
  mvc:
    static-path-pattern: /**
  resources:
    static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,cla
# feign的配置,连接超时及读取超时
feign:
  client:
    config:
      default:
        connectTimeout: 500000
        readTimeout: 500000
        loggerlevel: basic
  compression:
    request: #请求
      enabled: true #开启
      mime-types: text/xml,application/xml,application/json #开启支持压缩的MIME TYPE
      min-request-size: 2048 #配置压缩数据大小的下限
      response: #响应
        enabled: true #开启响应GZIP压缩
#hystrix的超时时间
hystrix:
  command:
    default:
      execution:
        timeout:
          enabled: true
        isolation:
          strategy: SEMAPHORE
          thread:
            timeoutInMilliseconds: 2170000   #设置调用者等待命SEMAPHORE令执行的超时限制,超过此时间,HystrixCommand被标记为TIMEOUT,并执行回退逻辑
      circuitBreaker:
        requestVolumeThreshold: 2000     #设置在一个滚动窗口中,打开断路器的最少请求数
        sleepWindowInMilliseconds: 5000 #设置在回路被打开,拒绝请求到再次尝试请求并决定回路是否继续打开的时间
        errorThresholdPercentage: 50    #设置打开回路并启动回退逻辑的错误比率
  threadpool:
    default:
      coreSize: 2000                   #核心线程数
      maxQueueSize: 2000               #最大队列数
      queueSizeRejectionThreshold: 160   #队列拒绝阈值设置
env: cksdev
port: 9000
info: master 分支 base  cksdev 环境, version=01

客户端的bootstrap.yml

spring:
  main:
    allow-bean-definition-overriding: true
  cloud:
    config:
      fail-fast: true
      label: master # 指定分支
      name: base # 指定应用名称
      profile: cksdev # 指定激活环境
      #      uri: http://localhost:7009 #硬编码 指定访问 config server 远程仓储的地址的ip和端口
      discovery:
        service-id: CONFIG-SERVICE  # 大写 告诉当前客户端 统一配置中心的服务端服务id
        enabled: true #开启客户端,根据服务id到注册中心获取配置信息
      retry:
        initial-interval: 2000
        max-attempts: 2000
        max-interval: 2000
        multiplier: 1.2
    bus:
      refresh:
        enabled: true
  # 通过bus消息总线组件连接到 MQ 服务
  rabbitmq: # 通过bus消息总线组件连接到 MQ 服务
    host: x.xxx.xx.xx
    port: 5000
    username: xxx
    password: xxx

#暴露服务端点,让客户端能感受到配置的更新
management:
  security:
    enabled: false
  endpoints:
    web:
      exposure:
        include: "*"

## 配置eureka客户端信息
eureka:
  client:
    service-url:
      defaultZone: http://localhost:9999/eureka/

  • 写回答

1条回答 默认 最新

  • a1767028198 2023-04-11 19:04
    关注

    PropertySourceLocator debug看看获取到的yml到底是啥

    评论

报告相同问题?

问题事件

  • 创建了问题 4月11日

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算