现在我们的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. JDK源码分析:Integer.java部分源码解析

    1)声明部: public final class Integer extends Number implements Comparable<Integer> extends Number ...

  2. 【Python 开发】第二篇 :Python安装

    一.python3.x安装 1)由于centos7原本就安装了Python2,而且这个Python2不能被删除,因为有很多系统命令,比如yum都要用到. 官网:https://www.python.o ...

  3. tensorflow学习笔记(3)前置数学知识

    tensorflow学习笔记(3)前置数学知识 首先是神经元的模型 接下来是激励函数 神经网络的复杂度计算 层数:隐藏层+输出层 总参数=总的w+b 下图为2层 如下图 w为3*4+4个   b为4* ...

  4. 使用树莓派实现(山寨)高清视频叠加(HDMI OSD)

    项目需要在HDMI上叠加一些字符包括汉字和数值,要求不能使用台式机,本身也没有HDMI采集卡驱动开发能力,所以通过海思的HDMI编码器将HDMI编码为h.264网络视频流,然后通过树莓派解码显示,做字 ...

  5. Martin Fowler关于IOC和DI的文章(原版)

    Inversion of Control Containers and the Dependency Injection pattern In the Java community there's b ...

  6. TCP系列15—重传—5、Linux中RTO的计算

    之前我们介绍的都是协议中给出的RTO计算方法,下面我们看一下linux实现中RTO的计算方法.在linux中维护了srtt.mdev.mdev_max.rttvar.rtt_seq几个状态变量用来计算 ...

  7. 个人github blog环境设置

    每个人都想拥有自己的网站,但是大部分比较屌丝,不想花钱租赁服务器,哈哈,屌丝有屌丝办法.github应该都听说过吧,github.io提供了此功能,而且使用github来管理自己的代码,如果你有域名, ...

  8. 3dContactPointAnnotationTool开发日志(二十)

      为了使工具更人性化,我又在每个status的text上绑了个可以拖拽实现值改变的脚本,但是不知道为啥rotx那个值越过+-90范围后连续修改就会产生抖动的现象,试了很多方法也没能弄好,不过实际用起 ...

  9. 【week3】psp (技术随笔)

    本周psp: 随笔字数: 总计 累计代码行 (前两项为单元测试部分) 词频统计:87 四则运算:49 四人小组:39 175 随笔字数 (不包含代码字数) 词频统计:237 四则运算:125 四人小组 ...

  10. 【week3】四则运算 单元测试

    上一周的四则运算有bug,这次补充正确代码: // 中缀转后缀 public String[] SolveOrder(String[] in, HashMap<String, Integer&g ...