SpringBoot中application.yml的一些配置模板

  • Post author:
  • Post category:其他


纪录一下使用过的相关yml配置



security相关的:
security:
  oauth2:
    resource:
      prefer-token-info: true
      token-info-uri: http://sc-security-uaa/oauth/token
      jwt:
        key-value: secret
        key-uri: http://sc-security-uaa/oauth/token_key
    client:
      client-id: client
      client-secret: client
      grant-type: client_credentials
      access-token-uri: http://sc-security-uaa/oauth/token
      user-authorization-uri: http://sc-security-uaa/oauth/authorize
  sessions: stateless
  

Security登入相关

security:
	login:
#      限制用户登录用户名或密码错误次数
		max-fail:
#      是否开启
        enabled: true
#        时长,单位为分钟
        interval: 5
#        错误次数
        times-before-lock: 5


oauth2中在Security内相关定义

oauth2相关

 oauth2:
      browser:
        client-id: webapp
        client-secret: webapp
        grant-type: password
        scope: all

验证码相关

 validate-code:
      image:
        expire-in: 180
        height: 40
        width: 200
        count: 4


Redis相关:
  redis:
    host: 127.0.0.1
    password: 123456
    database: 9


spring默认相关:
spring:
  datasource:
    name: dataSource
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true
    username: root
    password: root
    druid:
      initialSize: 1
      minIdle: 1
      maxActive: 20
      maxWait: 60000
      validationQuery: select 'x' from dual
      timeBetweenEvictionRunsMillis: 60000
      minEvictableIdleTimeMillis: 300000
      testWhileIdle: true
      testOnBorrow: false
      testOnReturn: false
      filters: stat,slf4j
      web-stat-filter:
        exclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.woff2,*.ico,/druid/*,/swagger*,/v2/api-docs'
      stat-view-servlet:
        enabled: true
        login-username: admin
        login-password: 123456
      filter:
        stat:
          enabled: true
          log-slow-sql: true
          slow-sql-millis: 1000
          merge-sql: true
        slf4j:
          enabled: true
          statement-executable-sql-log-enable: false
          connection-log-enabled: false
          result-set-log-enabled: false


mybatis相关
mybatis:
  mapper-locations: classpath:mybatis/mapper/**/*Mapper.xml
  config-location: classpath:mybatis/mybatis-config.xml


Spring Cloud 相关
sc:
  cloud:
    debug: true
    task:
      core-pool-size: 20
      max-pool-size: 50
      queue-capacity: 200
      keep-alive-seconds: 3000
      thread-name-prefix: sc-task-executor-
    swagger:
      enabled: true
      description: 'spring cloud module Template project '


Spring Cloud Task 相关
 task:
      core-pool-size: 20
      max-pool-size: 50
      queue-capacity: 200
      keep-alive-seconds: 3000
      thread-name-prefix: sc-task-executor-


rocketmq 相关
rocketmq:
      logging: true
      tag: tag
      topic: log
      producer-group: default
      name-server-address: 127.0.0.1:8080


eureka服务注册相关
eureka:
  client:
    #是否注册自己
    registerWithEureka: false
    #获取客户端信息
    fetchRegistry: false
  server:
    enable-self-preservation: false


Spring Cloud Ribbon 相关
ribbon:
  ConnectTimeout: 60000
  ReadTimeout: 60000
  MaxAutoRetries: 0
  MaxAutoRetriesNextServer: 1


断路器Hystrix相关
hystrix:
  command:
    default:
      execution:
        isolation:
          thread:
            timeout-in-milliseconds: 20000


ZUUL-API网关 相关
zuul:
  routes:
    uaa:
      path: /uaa/**
      serviceId: sc-security-uaa
    web:
      path: /web/**
      serviceId: sc-web
      sensitiveHeaders:
    webauth:
      path: /webauth/**
      serviceId: sc-web-auth
      sensitiveHeaders:
    job:
      path: /job/**
      serviceId: sc-job
      sensitiveHeaders:
    project:
      path: /project/**
      serviceId: sc-project
      sensitiveHeaders:
    pcclient:
      path: /pcclient/**
      serviceId: sc-example-pcclient
      sensitiveHeaders:
    appclient:
      path: /appclient/**
      serviceId: sc-example-appclient
      sensitiveHeaders:
  add-proxy-headers: true
  add-host-header: true
  retryable: false



版权声明:本文为CharLINHeng原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。