您的位置:首页 > 编程语言 > Java开发

springBoot yaml/properties 文件配置参数解析

2019-04-04 14:25 405 查看

在spring boot项目中可以使用俩种 配置文件 一中是 .yaml 结尾的 一种是 .properties 结尾的
Spring Boot 在启动时,就会从 application中读取配置信息,并加载到内存中。以下是配置文件的一些参数解析:

配置项 说明 举例
server.port 应用程序启动端口 server.port=8080,定义应用程序启动端口为 8080
server.servlet.context-path 应用程序上下文 server.servlet.context-path=/api,则访问地址为:http://ip:port/api
spring.servlet.multipart.maxFileSize 最大文件上传大小,-1为不限制 spring.servlet.multipart.maxFileSize=-1
spring.jpa.database 数据库类型 spring.jpa.database=MYSQL,指定数据库为mysql
spring.jpa.properties.hibernate.dialect hql方言 spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.datasource.url 数据库连接字符串 spring.datasource.url=jdbc:mysql://localhost:3306/database?useUnicode=true&characterEncoding=UTF-8&useSSL=true
spring.datasource.username 数据库用户名 spring.datasource.username=root
spring.datasource.password 数据库密码 spring.datasource.password=root
spring.datasource.driverClassName 数据库驱动 spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.jpa.showSql 控制台是否打印 SQL 语句 spring.jpa.showSql=true
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: