1. 程式人生 > 其它 >29、我的雲伺服器Nacos配置中心

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