在spring boot项目中,可以通过两种格式的文件来作为配置文件:application.yml和application.properties。格式如下:
一)application.yml格式为
server:
port: 8088
servlet:
context-path: /test-demo
tomcat:
uri-encoding: utf-8
spring:
datasource:
druid:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8
username: root
password: root
mybatis:
config-location: classpath:config/mybatis-config.xml
# type-aliases扫描路径
type-aliases-package: com.test.demo.system.domain
# mapper xml实现扫描路径
mapper-locations: classpath:mapper/**/*.xml
property:
order: BEFORE
#mappers 多个接口时逗号隔开
mapper:
mappers: com.tilchina.mis.common.dao.BaseMapper
not-empty: false
identity: mysql
二)application.properties格式为:
#默认端口8088,此处自定义
server.port=8088
#服务器路径
#session最大超时时间(分钟),默认为30
#server.session.timeout=60
#数据库
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=root
#配置mybatis映射文件路径
mybatis.mapper-locations=classpath:/mappers/*Mapper.xml
#配置log
logging.file=demo.log
#logging.path=F:/springboot_logs
logging.level.root=info
# 配置编码集
spring.http.encoding.charset=UTF-8
server.tomcat.uri-encoding=UTF-8
spring.http.encoding.force=true
spring.http.encoding.enabled=true
#设置最大request size
spring.http.multipart.maxFileSize=100Mb
spring.http.multipart.maxRequestSize=100Mb