现在我们的application.properties文件内容是:

  1. server.port=8090
  2. server.session-timeout=30
  3. server.context-path=
  4. server.tomcat.max-threads=0
  5. server.tomcat.uri-encoding=UTF-8
  6. spring.datasource.url = jdbc:mysql://localhost:3306/newbirds
  7. spring.datasource.username = root
  8. spring.datasource.password = mymysql
  9. spring.datasource.driverClassName = com.mysql.jdbc.Driver
  10. # Specify the DBMS
  11. spring.jpa.database = MYSQL
  12. # Show or not log for each sql query
  13. spring.jpa.show-sql = true
  14. # Hibernate ddl auto (create, create-drop, update)
  15. spring.jpa.hibernate.ddl-auto = update
  16. # Naming strategy
  17. spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
  18. # stripped before adding them to the entity manager)
  19. spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

而官方给的很多demo,都是用yml文件配置的。

yml文件的好处,天然的树状结构,一目了然。不过当时把application.properties 改成 application.yml还是痛苦了一会儿。

下面是置换后的application.yml内容:

  1. server:
  2. port: 8090
  3. session-timeout: 30
  4. tomcat.max-threads: 0
  5. tomcat.uri-encoding: UTF-8
  6. spring:
  7. datasource:
  8. url : jdbc:mysql://localhost:3306/newbirds
  9. username : root
  10. password : mymysql
  11. driverClassName : com.mysql.jdbc.Driver
  12. jpa:
  13. database : MYSQL
  14. show-sql : true
  15. hibernate:
  16. ddl-auto : update
  17. naming-strategy : org.hibernate.cfg.ImprovedNamingStrategy
  18. properties:
  19. hibernate:
  20. 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的区别的更多相关文章

  1. SpringBoot读取application.properties文件

    http://blog.csdn.net/cloume/article/details/52538626 Spring Boot中使用自定义的properties Spring Boot的applic ...

  2. SpringBoot配置文件 application.properties详解

    SpringBoot配置文件 application.properties详解   本文转载:https://www.cnblogs.com/louby/p/8565027.html 阅读过程中若发现 ...

  3. SpringBoot获得application.properties中数据的几种方式

    转:https://blog.csdn.net/qq_27298687/article/details/79033102 SpringBoot获得application.properties中数据的几 ...

  4. SpringBoot配置文件 application.properties,yaml配置

    SpringBoot配置文件 application.properties,yaml配置 1.Spring Boot 的配置文件 application.properties 1.1 位置问题 1.2 ...

  5. SpringBoot properties和yml的区别

    一.先附一个yml文件的解析步骤 1.Maven依赖 <dependency> <groupId>org.yaml</groupId> <artifactId ...

  6. springboot 配置 application.properties相关

    springboot 有读取外部配置文件的方法,如下优先级: 第一种是在jar包的同一目录下建一个config文件夹,然后把配置文件放到这个文件夹下.第二种是直接把配置文件放到jar包的同级目录.第三 ...

  7. springboot动态读取properties 和yml的配置

    properties使用PropertiesLoaderUtils,yml使用YamlPropertySourceLoader application.properties microsoft.def ...

  8. SpringBoot读取application.properties中文乱码

    [本文版权归微信公众号"代码艺术"(ID:onblog)所有,若是转载请务必保留本段原创声明,违者必究.若是文章有不足之处,欢迎关注微信公众号私信与我进行交流!] 解决方案 在ID ...

  9. SpringBoot 配置文件 application.properties

    转:http://www.qiyadeng.com/post/spring-boot-application-properties #########COMMON SPRING BOOT PROPER ...

随机推荐

  1. Spring Cloud(五):Hystrix 监控面板【Finchley 版】

    Spring Cloud(五):Hystrix 监控面板[Finchley 版]  发表于 2018-04-16 |  更新于 2018-05-10 |  在上一篇 Hystrix 的介绍中,我们提到 ...

  2. 78[LeetCode] Subsets

    Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solut ...

  3. ElasticSearch 论坛搜索查询语句

    概述 研究论坛搜索如何综合时间和TF/IDF权重. 自定义权重计算的效率问题 数据结构 假设有一个论坛的搜索 字段包括: subject:标题 message:内容 dateline:发布时间 tag ...

  4. HADOOP/HDFS Essay

    HDFS架构 the core of HADOOP/distributed systems is storeage(HDFS) and resource manager(YARN) for compu ...

  5. win10下搭建私链

    首先要下载geth,下载地址:https://gethstore.blob.core.windows.net/builds/geth-windows-amd64-1.7.0-6c6c7b2a.exe ...

  6. Juice账号

    zhangxiaocong69 zxc6545398 15657167502 区块链账户: 0x00680404766965143796a0a070835c3cdf9a4a50

  7. c# winform 服务器提交了协议冲突. Section=ResponseStatusLine

    [转] 最近在用.net写一个网络蜘蛛,发现对有的网站用HttpWebrequest抓取网页的时候会报错,捕获异常提示:"服务器提交了协议冲突 Section=ResponseStatusL ...

  8. Thunder团队第六周 - Scrum会议2

    Scrum会议2 小组名称:Thunder 项目名称:i阅app Scrum Master:宋雨 工作照片: 参会成员: 王航:http://www.cnblogs.com/wangh013/ 李传康 ...

  9. 用逗号隔开简单数据保存为csv

    用记事本编辑简单数据,用英文逗号隔开,编辑为多列,保存为.csv文件.可以用Excel打开编辑.

  10. python学习笔记06:操作文件

    调用内置的open函数打开文件,传递两个参数:文件路径(绝对路径或相对路径),打开模式('r':读,'r+':读写,'w':写,'b':二进制): f = open('data.txt','w') f ...