29我的云服务器Nacos配置中心

Posted shunWcs

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了29我的云服务器Nacos配置中心相关的知识,希望对你有一定的参考价值。

1、我的项目里的bootstrap-prod.yml 配置文件内容

server:
  port: 8084
  shutdown: graceful
spring:
  application:
    name: employee-base-server
  rabbitmq:
    host: 8.129.215.115
    port: 5672
    username: rabbit
    password: 123456
  lifecycle:
    timeout-per-shutdown-phase: 30
  redis:
    host: 8.129.215.115
  cloud:
    nacos:
      discovery:
        namespace: 11259da7-22d3-4afc-a309-60f1f7a8e891
        server-addr: 8.129.215.115:8848
      config:
        namespace: 11259da7-22d3-4afc-a309-60f1f7a8e891
        server-addr: 8.129.215.115:8848
        enabled: true
        file-extension: yaml
        extension-configs:
          - data-id: datasource.yaml
            group: ${spring.application.name}
            refresh: true
          - data-id: swagger.yaml
            group: ${spring.application.name}
            refresh: true
          - data-id: server-config.yaml
            group: ${spring.application.name}
            refresh: true
          - data-id: xxl-job.yaml
            group: ${spring.application.name}
            refresh: true
        refresh:
          enabled: true
  main:
    allow-bean-definition-overriding: true

2、nacos上的配置datasource.yaml 数据源的配置

spring:
  application:
    name: employee-base-server
  datasource:
    type: com.zaxxer.hikari.HikariDataSource
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://8.129.215.115:3307/myemployees?useUnicode=true&characterEncoding=utf-8&useSSL=false
    username: root
    password: 123456
    hikari:
      minimum-idle: 5
      idle-timeout: 600000
      maximum-pool-size: 10
      auto-commit: true
      pool-name: MyHikariCP
      max-lifetime: 1800000
      connection-timeout: 30000
      connection-test-query: SELECT 1

3、nacos里面的swagger.yaml swagger的配置

swagger:
  title: 员工系统
  description: 员工服务接口文档说明
  version: 1.0

4、服务器的其他配置server-config.yaml

feign:
  client:
    config:
      default:
        connect-timeout: 10000
        read-timeout: 20000
      service-test:
        connect-timeout: 10000
        read-timeout: 20000

logging:
  config: classpath:logback.xml
  level:
    com.wcs.base.employee.server.mapper: debug

mybatis:
    type-aliases-package: com.wcs.base.employee.server.entity
    mapper-locations: classpath:mapper/*.xml
    configuration:
      map-underscore-to-camel-case: true

management:
  endpoints:
    web:
      exposure:
        include: "*"

config:
  info: 测试nacos配置中心的例子66666

5、xxl-job.yaml的配置,如果不需要可以不配置

xxl:
  job:
    accessToken: \'\'
    admin:
      addresses: http://192.168.28.139:8010/xxl-job-admin
    executor:
      appname: xxl-job-executor-employee
      ip: \'\'
      logpath: /data/applogs/xxl-job/jobhandler
      logretentiondays: 30
      port: 9998

 

以上是关于29我的云服务器Nacos配置中心的主要内容,如果未能解决你的问题,请参考以下文章

配置 Nacos 注册中心

在K8S中部署Nacos配置中心

3. nacos服务发现

Docker下,两分钟极速体验Nacos配置中心

Docker下Nacos配置应用开发

Nacos:服务注册及配置中心