springboot的application.yml配置

本文主要探讨了SpringBoot项目中如何进行application.yml的配置,包括整合Mybatis和Thymeleaf的具体步骤,深入解析了配置文件的结构和常用属性,帮助读者理解并熟练掌握SpringBoot的配置管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

springboot+mybatis+thymeleaf

server:
  port: 443 #项目端口号
  ssl: #ssl证书配置
    key-store: classpath:client.pfx
    key-store-type: PKCS12
    key-store-password: e9wb6Go8
web: #服务器静态资源路径
  upload-path: /www/server/webapps/upload
  front-path: /www/server/webapps/upload
spring:
  servlet:
    multipart:
      enabled: true #是否启用http上传处理
      max-request-size: 100MB #最大请求文件的大小
      max-file-size: 20MB #设置单个文件最大长度
      file-size-threshold: 20MB #当文件达到多少时进行磁盘写入
  datasource:
    #mysql5 中com.mysql.jdbc.Driver
    #mysql6 中com.mysql.cj.jdbc.Driver  注意连接时需要指定时区serverTimezone
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/fangdichan?serverTimezone=UTC&characterEncoding=utf-8
    username: #数据库账号
    password: #数据库密码
    type: com.alibaba.druid.pool.DruidDataSource
  resources: #项目中静态资位置
    static-locations : classpath:/static/,file:${web.upload-path},file:${web.front-path}
  devtools:
    restart:
      enabled: true  #设置开启热部署
      additional-paths: src/main/java #重启目录
      exclude: classpath:/templates/
  freemarker:
    cache: false    #页面不加载缓存,修改即时生效
  template:
    cache: false
  thymeleaf:
    prefix: classpath:/templates/  #prefix:指定模板所在的目录
    check-template-location: true  #check-tempate-location: 检查模板路径是否存在
    cache: false  #cache: 是否缓存,开发模式下设置为false,避免改了模板还要重启服务器,线上设置为true,可以提高性能。
    suffix:  .html
    #encoding: UTF-8
    #content-type: text/html
    mode: HTML5
  mvc:
    dateFormat: yyyy-MM-dd HH:mm:ss #配置时间格式前台传时间要转成该格式,否者会报错
    favicon:
      enabled: false #关闭springboot自带的favicon图标
  jackson:
    date-format: yyyy-MM-dd HH:mm:ss #配置时间格式前台传时间要转成该格式,否者会报错
    time-zone: GMT+8
mybatis:
  #扫描classpath中mapper目录下的映射配置文件,针对与映射配置文件放到了resource目录下
  mapper-locations: classpath:mapper/*.xml
  #标签作用mapper.xml中返回pojo时不需要写包名,直接写对象名即可
  type-aliases-package: com.bz.bean
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值