application配置详解

application配置详解

application.yml

server:
  port: 80
  servlet:
    context-path: /
spring:
  application:
    name: applicatin-server
  profiles:
    active: dev

application-dev.yml

spring:
  jackson:
    date-format: yyyy-MM-dd HH:mm:ss
    time-zone: GMT+8
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/db?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false
    username: root
    password: root
    type: com.alibaba.druid.pool.DruidDataSource
    initialSize: 2
    minIdle: 2
    maxActive: 3
    maxWait: 6000
    pool-prepared-statements: true
    max-pool-prepared-statement-per-connection-size: 10
    timeBetweenEvictionRunsMillis: 60000
    minEvictableIdleTimeMillis: 300000
    validationQuery: SELECT 1 FROM DUAL
    testWhileIdle: true
    testOnBorrow: false
    testOnReturn: false
    # 注意:这里有个重复的属性,保留一个即可
    poolPreparedStatements: true
    maxPoolPreparedStatementPerConnectionSize: 20
    filters: stat,wall,log4j
    connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000

mybatis:
  typeAliasesPackage: com.hanyuanhun.**.entity
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

mybatis-plus:
  mapper-locations: classpath*:/mappers/**/*.xml

logging:
  config: classpath:logback-spring.xml

transaction:
  rollback-on-commit-failure: true

application-prod.yml

以上是application.ymlapplication-dev.yml文件内容的Markdown格式化展示。注意在实际配置中,poolPreparedStatements属性出现了两次,应当只保留一个。

原文链接 https://www.hanyuanhun.cn | https://node.hanyuanhun.cn

posted @ 2024-06-26 09:54  汉源魂  阅读(18)  评论(0)    收藏  举报