Detailed configuration of spring-boot-plus

Public Configuration application.yml

👉 Official Full Configuration for SpringBoot

Tomcat related configuration

server:
  servlet:
    context-path: /api
  tomcat:
    max-threads: 1000
    min-spare-threads: 30
    uri-encoding: UTF-8
  • context-path: project access path
  • max-threads:tomcat thread pool size setting
  • min-spare-threads: number of tomcat initialization threads
  • uri-encoding:tomcat encoding

Application-related configurations

spring:
  application:
    name: spring-boot-plus
  banner:
    charset: UTF-8
    location: classpath:config/banner.txt
  • spring.application.name: Project name
  • banner.charset:banner character set
  • banner.location:banner file path

Database Driven and DRUID Data Source Configuration

datasource:
    driver-class-name: com.mysql.jdbc.Driver
    druid:
      filter:
        slf4j:
          enabled: true
        stat:
          log-slow-sql: true
          merge-sql: true
          slow-sql-millis: 3000
        wall:
          config:
            delete-allow: true
            drop-table-allow: false
          enabled: true
      filters: stat,wall,slf4j
      initial-size: 10
      max-active: 100
      max-pool-prepared-statement-per-connection-size: 20
      max-wait: 60000
      min-evictable-idle-time-millis: 300000
      min-idle: 10
      pool-prepared-statements: true
      stat-view-servlet:
        enabled: true
        login-password: druid123
        login-username: druid
        url-pattern: /druid/*
      test-on-borrow: false
      test-on-return: false
      test-while-idle: true
      time-between-eviction-runs-millis: 60000
      validation-query: SELECT 1 FROM DUAL
    type: com.alibaba.druid.pool.DruidDataSource
  • driver-class-name: database driver class name
  • slow-sql-millis: SQL slow query time, defined here as more than 3 seconds and slow query, which prints ERROR logs
  • url-pattern:druid login path
  • login-username:druid login account
  • login-password:druid login password
  • More instructions and configurations for druid: https://github.com/alibaba/druid

HTTP Encoding

http:
    encoding:
      charset: UTF-8
      enabled: true
      force: true

Jackson Date and Time Zone Configuration

jackson:
    date-format: yyy-MM-dd HH:mm:ss
    time-zone: GMT+8

Current Project Environment Configuration

profiles:
    active: '@profileActive@'

Redis Configuration

redis:
    jedis:
      pool:
        max-active: 2000
        max-wait: -1ms
        min-idle: 8
        max-idle: 200
    timeout: 10s
    lettuce:
      pool:
        max-active: 200
        max-idle: 8
        max-wait: 10s
        min-idle: 2
      shutdown-timeout: 3s
  • max-active: maximum number of activations
  • max-wait: maximum wait time, -1ms identity has been waiting, can be modified according to actual situation
  • min-idle: minimum survival
  • max-idle: minimum survival
  • Timeout: timeout

Rabbit MQ Configuration

  rabbitmq:
    host: 39.106.37.56
    port: 5672
    username: admin
    password: admin123
    template:
      # Enable retry mechanism with a retry interval of 2 seconds and a maximum of 3 retries
      retry:
        enabled: true
        initial-interval: 2s
        max-attempts: 3
      queue: spring-boot-plus-queue
      # Define the default switch name
      exchange: spring-boot-plus-exchange
      # Define the default routing key
      routing-key: spring-boot-plus-key
  • Host:rabbitmq server host
  • Port: port
  • username: account
  • Password: password
  • retry.enabled: Enable retry mechanism
  • retry.initial-interval: retry interval
  • retry.max-attempts: maximum number of retries
  • Queue: queue name
  • exchange: switch name
  • routing-key: routing key name

Kafka MQ Configuration

kafka:
    bootstrap-servers: 203.104.37.38:9092
    producer:
      retries: 0
      batch-size: 4096
      buffer-memory: 40960
    consumer:
      group-id: spring-boot-plus-group
    template:
      default-topic: spring-boot-plus-topic
  • bootstrap-servers:server host and port
  • Producer: producer configuration
  • Consumer: consumer configuration
  • default-topic: default theme configuration

JWT Configuration

spring-boot-plus:
  jwt:
    header: token
    secret: 666666
    issuer: spring-boot-plus
    subject: spring-boot-plus-jwt
    audience: web
    expire-minutes: 2
  • Header: jwt name in request header
  • secret: password
  • issuer: publisher
  • Subject: subject
  • audience: application scenarios
  • expire-minutes: expire minutes
  • More details: https://jwt.io/

Interceptor Path Exclusion Configuration

interceptor:
    jwt:
      exclude:
        path: /swagger-resources/**,/api-docs/**,/v2/api-docs/**,/login,/verificationCode,/doc/**,/error/**,/docs,/test/**

    permission:
      exclude:
        path: /swagger-resources/**,/api-docs/**,/v2/api-docs/**,/adminLogin,/sysLogin,/login.html,/verificationCode,/doc/**,/error/**,/docs

    token-timeout:
      exclude:
        path: /swagger-resources/**,/api-docs/**,/v2/api-docs/**,/docs
  • jwt.exclude.path:jwt interceptor exclusion path
  • permission.exclude.path: permission interceptor exclusion path
  • token-timeout.exclude.path:token timeout interceptor exclusion path

mybatis-plus configuration

mybatis-plus:
  check-config-location: true
  configuration:
    map-underscore-to-camel-case: true
  global-config:
    db-config:
      field-strategy: not_empty
      id-type: id_worker
      logic-delete-value: 0
      logic-not-delete-value: 1
  mapper-locations: classpath*:mapper/**/*Mapper.xml
  • check-config-location: check path configuration
  • map-underscore-to-camel-case: downline automatic hump
  • id-type: Primary key generation policy, id_worker uses the snowflake algorithm to generate a globally unique ordered ID
  • mapper-locations: mapper xml path
  • For more mybatis-plus configurations, see_ https://mybatis.plus/config/

Swagger2 Configuration

swagger:
  base:
    package: io.geekidea.springbootplus
  contact:
    email: geekidea@qq.com
    name: geekidea
    url: ''
  description: ''
  title: spring-boot-plus
  url: ''
  version: 1.0
  • Package:swagger scanned package
  • email: developer mailbox
  • Name: developer name
  • Title: title
  • Description: description
  • More details: https://swagger.io/

Spring Boot Admin Background Monitoring Configuration

spring:
  boot:
    admin:
      client:
        url: 'http://localhost:8888'

management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS

Project custom attribute configuration, used in conjunction with spring boot admin

info:
  project-groupId: '@project.groupId@'
  project-artifactId: '@project.artifactId@'
  project-name: '@project.name@'
  project-finalName: '@project.build.finalName@'
  project-author: ${swagger.contact.name}
  project-description: '@project.description@'
  project-sourceEncoding: '@project.build.sourceEncoding@'
  project-spring-boot-version: '@spring-boot.version@'
  project-mybatis-plus-version: '@mybatis-plus-boot-starter.version@'
  project-version: '@project.version@'
  • project-groupId: Project maven group ID
  • project-artifactId: Project skeleton ID
  • project-name: project name
  • project-finalName: The name of the packaged project
  • project-author: project author
  • project-description: project description
  • project-sourceEncoding: Project source code encoding
  • project-spring-boot-version:spring boot version
  • project-mybatis-plus-version:mybatis-plus version
  • project-version: project version

Local environment application-local.yml

Local environment-related configuration, which will be overwritten if there is one in the public configuration

Logon token timeout configuration

springbootplus:
  isEnableAnsi: true
  login:
    token:
      valid:
        time:
          minute: 3600
  • isEnableAnsi: Whether the console logs are colored, the local development environment can be set to true, and the server environment to false
  • minute:token timeout minutes

Port Related Configuration

server:
  port: 8888
  servlet:
    context-path: /
  • Port: Local environment port
  • context-path: local environment project path

Database Related Configuration

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/spring_boot_plus?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
    username: root
    password: root
  • url: database connection information
  • username: account
  • Password: password

redis related configuration

redis:
    database: 0
    host: localhost
    password:
    port: 6379
  • Database: database serial number
  • Host: host
  • Password: password
  • port: password

Other environments are similar to local environments

Tags: Java Spring Druid Mybatis Database

Posted on Mon, 12 Aug 2019 09:13:30 -0700 by mjs87