Version: Next
典型配置文件
info
包含了常用配置项目的典型配置文件
- Datasource:数据库
- jackson:SpringBoot自带Json工具
- mybatis:配置mapper.xml扫描路径,开启驼峰映射,开启日志打印
- server.port:访问端口
- logging:配置日志框架
- JWT:这部分不用写,只有用到JWT的项目才写
application.yaml
spring:
datasource:
username: root
password: root
url: jdbc:mysql://localhost:3306/oauth?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8
driver-class-name: com.mysql.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
initialSize: 5
minIdle: 5
maxActive: 20
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
filters: stat,wall,log4j
maxPoolPreparedStatementPerConnectionSize: 20
useGlobalDataSourceStat: true
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500
jackson: # SpringBoot内部默认使用的JSON工具是jackson,它默认的日期格式不是中国人熟悉的模式
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
mybatis:
mapper-locations: classpath:mapper/*.xml
configuration:
map-underscore-to-camel-case: true #驼峰映射
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #调试打印SQL
server:
port: 8081
logging: # 配置Log4j2配置文件
config: classpath:log4j2.xml
jwt:
enabled: true # 开启
secret: fjkfaf;afa # Jwt密文
expiration: 3600000
header: JWTHeaderName # 头名称
userParamName: username # 前端组件名称
pwdParamName: password # 前端组件名称
useDefaultController: true # 使用默认Controller
corsAllowedOrigins: # 设置允许跨域的地址
- http://localhost:8888
- http://localhost:8080
corsAllowedMethods: # 允许的请求方式
- GET
- POST
csrfDisabled: true # 是否开启CSRF防御
permitAllURI: # 总是允许访问的路径,无序JWT
- /authentication
- /refreshtoken
# - /roles
devOpeningURI: # 开发时临时允许访问的url地址
- /sysuser/info
- /sysorg/tree
# - /authentication
# - /refreshtoken
# - /roles