yml配置文件快速上手

yml配置文件快速上手

springboot中,有三种文件可以作为配置文件

  • xml文件(不推荐,臃肿)
  • application.propertis文件(层次不够分明)
  • yml文件(推荐,层次分明,语法简洁)

在这里插入图片描述

yml文件的基本语法

在这里插入图片描述

yml文件的注意事项
  • 大小写敏感
  • 数值前面必须有空格作为分隔符
  • 使用缩进表示层级关系,缩进时不能使用tab间,只能使用空格
  • 缩进的空格数目不重要,只要相同层级的元素左侧对齐即可
  • 使用#表示注释,从这个字符一直到行尾

使用示例

server:
  port: 8080

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/test
    username: root
    password: 1234

  servlet:
    multipart:
      max-file-size: 10MB
      max-request-size: 100MB

mybatis:
  configuration:
    map-underscore-to-camel-case: true
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

aliyun:
  oss:
    endpoint: https://oss-cn-shanghai.aliyuncs.com
    bucketName: terminal

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值