springboot的application.properties与.yml的区别
现在我们的application.properties文件内容是:
- server.port=8090
- server.session-timeout=30
- server.context-path=
- server.tomcat.max-threads=0
- server.tomcat.uri-encoding=UTF-8
- spring.datasource.url = jdbc:mysql://localhost:3306/newbirds
- spring.datasource.username = root
- spring.datasource.password = mymysql
- spring.datasource.driverClassName = com.mysql.jdbc.Driver
- # Specify the DBMS
- spring.jpa.database = MYSQL
- # Show or not log for each sql query
- spring.jpa.show-sql = true
- # Hibernate ddl auto (create, create-drop, update)
- spring.jpa.hibernate.ddl-auto = update
- # Naming strategy
- spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
- # stripped before adding them to the entity manager)
- spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
而官方给的很多demo,都是用yml文件配置的。
yml文件的好处,天然的树状结构,一目了然。不过当时把application.properties 改成 application.yml还是痛苦了一会儿。
下面是置换后的application.yml内容:
- server:
- port: 8090
- session-timeout: 30
- tomcat.max-threads: 0
- tomcat.uri-encoding: UTF-8
- spring:
- datasource:
- url : jdbc:mysql://localhost:3306/newbirds
- username : root
- password : mymysql
- driverClassName : com.mysql.jdbc.Driver
- jpa:
- database : MYSQL
- show-sql : true
- hibernate:
- ddl-auto : update
- naming-strategy : org.hibernate.cfg.ImprovedNamingStrategy
- properties:
- hibernate:
- dialect : org.hibernate.dialect.MySQL5Dialect
注意点:
1,原有的key,例如spring.jpa.properties.hibernate.dialect,按“.”分割,都变成树状的配置
2,key后面的冒号,后面一定要跟一个空格
3,把原有的application.properties删掉。然后一定要执行一下 maven -X clean install
springboot的application.properties与.yml的区别的更多相关文章
- SpringBoot读取application.properties文件
		http://blog.csdn.net/cloume/article/details/52538626 Spring Boot中使用自定义的properties Spring Boot的applic ... 
- SpringBoot配置文件 application.properties详解
		SpringBoot配置文件 application.properties详解 本文转载:https://www.cnblogs.com/louby/p/8565027.html 阅读过程中若发现 ... 
- SpringBoot获得application.properties中数据的几种方式
		转:https://blog.csdn.net/qq_27298687/article/details/79033102 SpringBoot获得application.properties中数据的几 ... 
- SpringBoot配置文件 application.properties,yaml配置
		SpringBoot配置文件 application.properties,yaml配置 1.Spring Boot 的配置文件 application.properties 1.1 位置问题 1.2 ... 
- SpringBoot properties和yml的区别
		一.先附一个yml文件的解析步骤 1.Maven依赖 <dependency> <groupId>org.yaml</groupId> <artifactId ... 
- springboot 配置 application.properties相关
		springboot 有读取外部配置文件的方法,如下优先级: 第一种是在jar包的同一目录下建一个config文件夹,然后把配置文件放到这个文件夹下.第二种是直接把配置文件放到jar包的同级目录.第三 ... 
- springboot动态读取properties 和yml的配置
		properties使用PropertiesLoaderUtils,yml使用YamlPropertySourceLoader application.properties microsoft.def ... 
- SpringBoot读取application.properties中文乱码
		[本文版权归微信公众号"代码艺术"(ID:onblog)所有,若是转载请务必保留本段原创声明,违者必究.若是文章有不足之处,欢迎关注微信公众号私信与我进行交流!] 解决方案 在ID ... 
- SpringBoot 配置文件 application.properties
		转:http://www.qiyadeng.com/post/spring-boot-application-properties #########COMMON SPRING BOOT PROPER ... 
随机推荐
- Spring Cloud(五):Hystrix 监控面板【Finchley 版】
			Spring Cloud(五):Hystrix 监控面板[Finchley 版] 发表于 2018-04-16 | 更新于 2018-05-10 | 在上一篇 Hystrix 的介绍中,我们提到 ... 
- 78[LeetCode] Subsets
			Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solut ... 
- ElasticSearch 论坛搜索查询语句
			概述 研究论坛搜索如何综合时间和TF/IDF权重. 自定义权重计算的效率问题 数据结构 假设有一个论坛的搜索 字段包括: subject:标题 message:内容 dateline:发布时间 tag ... 
- HADOOP/HDFS Essay
			HDFS架构 the core of HADOOP/distributed systems is storeage(HDFS) and resource manager(YARN) for compu ... 
- win10下搭建私链
			首先要下载geth,下载地址:https://gethstore.blob.core.windows.net/builds/geth-windows-amd64-1.7.0-6c6c7b2a.exe ... 
- Juice账号
			zhangxiaocong69 zxc6545398 15657167502 区块链账户: 0x00680404766965143796a0a070835c3cdf9a4a50 
- c# winform  服务器提交了协议冲突. Section=ResponseStatusLine
			[转] 最近在用.net写一个网络蜘蛛,发现对有的网站用HttpWebrequest抓取网页的时候会报错,捕获异常提示:"服务器提交了协议冲突 Section=ResponseStatusL ... 
- Thunder团队第六周 - Scrum会议2
			Scrum会议2 小组名称:Thunder 项目名称:i阅app Scrum Master:宋雨 工作照片: 参会成员: 王航:http://www.cnblogs.com/wangh013/ 李传康 ... 
- 用逗号隔开简单数据保存为csv
			用记事本编辑简单数据,用英文逗号隔开,编辑为多列,保存为.csv文件.可以用Excel打开编辑. 
- python学习笔记06:操作文件
			调用内置的open函数打开文件,传递两个参数:文件路径(绝对路径或相对路径),打开模式('r':读,'r+':读写,'w':写,'b':二进制): f = open('data.txt','w') f ... 
