springboot基本配置

server:
  port: 8081   #端口号
  servlet:
    context-path: /    #项目访问路径
spring:
  thymeleaf:
    prefix: classpath:/templates/
    suffix: .html
    encoding: UTF-8
    mode: LEGACYHTML5
    cache: false
  application:
    name: homework
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/stu_info?useUnicode=true&characterEncoding=UTF-8&useSSL=false
    username: root
    password: root
    type: com.alibaba.druid.pool.DruidDataSource
    druid:
        # 下面为连接池的补充设置,应用到上面所有数据源中
        # 初始化大小,最小,最大
        initial-size: 5
        min-idle: 5
        max-active: 20
        # 配置获取连接等待超时的时间
        max-wait: 60000
        # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
        time-between-eviction-runs-millis: 60000
        # 配置一个连接在池中最小生存的时间,单位是毫秒
        min-evictable-idle-time-millis: 300000
        validation-query: SELECT 1 FROM DUAL
        test-while-idle: true
        test-on-borrow: false
        test-on-return: false
        # 打开PSCache,并且指定每个连接上PSCache的大小
        pool-prepared-statements: true
        #   配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
        max-pool-prepared-statement-per-connection-size: 20
        filters: stat,wall
        use-global-data-source-stat: true
        # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
        connect-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
        # 配置监控服务器
        stat-view-servlet:
          login-username: admin
          login-password: 123456
          reset-enable: false
          url-pattern: /druid/*
          # 添加IP白名单
          #allow:
          # 添加IP黑名单,当白名单和黑名单重复时,黑名单优先级更高
          #deny:
        web-stat-filter:
          # 添加过滤规则
          url-pattern: /*
          # 忽略过滤格式
          exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"
  mvc:
    static-path-pattern: /static/**
  servlet:
    multipart:
      max-file-size: 10MB
      max-request-size: 10MB
mybatis-plus:
  mapper-locations: classpath*:/mapper/**/*.xml
  #MyBaits 别名包扫描路径,通过该属性可以给包中的类注册别名
  type-aliases-package: com.fwz.homework.user.entity
  check-config-location: true
  configuration:
    # 是否开启自动驼峰命名规则(camel case)映射,即从经典数据库列名 A_COLUMN(下划线命名) 到经典 Java 属性名 aColumn(驼峰命名) 的类似映射
    map-underscore-to-camel-case: true
    # 全局地开启或关闭配置文件中的所有映射器已经配置的任何缓存,默认为 true
    cache-enabled: false
    call-setters-on-nulls: true
    # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  global-config:
    db-config:
      #表名下划线命名默认true
      table-underline: true
      #id类型
      id-type: auto
      #数据库类型
      db-type: mysql
原文地址:https://www.cnblogs.com/fengwenzhee/p/15390365.html