application.properties 文件和 application.yml 文件有什麽區別呢?
阿新 • • 發佈:2018-04-21
tomcat ffi dst cati prepare odin oot lac all
application.properties 文件和 application.yml 文件有什麽區別呢?
yml文件的好處,天然的樹狀結構,一目了然,實質上跟properties是差不多的。
官方給的很多demo,都是用yml文件配置的。
註意點:
1,原有的key,例如spring.jpa.properties.hibernate.dialect,按“.”分割,都變成樹狀的配置
2,key後面的冒號,後面一定要跟一個空格
3,把原有的application.properties刪掉。然後一定要執行一下 maven -X clean install
#application.yml server: port: 8086 spring: datasource: name: test url: jdbc:mysql://192.168.1.112:3306/test username: root password: xxx # 使用druid數據源 type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.jdbc.Driver filters: stat maxActive: 20 initialSize: 1 maxWait: 60000 minIdle: 1 timeBetweenEvictionRunsMillis: 60000 minEvictableIdleTimeMillis: 300000 validationQuery: select ‘x‘ testWhileIdle: true testOnBorrow: false testOnReturn: false poolPreparedStatements: true maxOpenPreparedStatements: 20
#application.properties server.port=8085 spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource spring.datasource.url=jdbc:mysql://aliyuncs.com:3306/home?useUnicode=true&zeroDateTimeBehavior=convertToNull&autoReconnect=true spring.datasource.username=root spring.datasource.password=*** spring.datasource.driver-class-name=com.mysql.jdbc.Driver #mybatis.mapper-locations=classpath*:com/wanyu/fams/mapping/*Mapper.xml #mybatis.type-aliases-package=com.wanyu.fams.model spring.mvc.view.prefix=/WEB-INF/jsp/ spring.mvc.view.suffix=.jsp spring.druid.datasource.type=com.alibaba.druid.pool.DruidDataSource spring.druid.datasource.driverClassName=com.mysql.jdbc.Driver spring.druid.datasource.url=jdbc:mysql://localhost:3306/spring_boot?characterEncoding=utf-8 spring.druid.datasource.username=root spring.druid.datasource.password=xxx
application.properties 文件和 application.yml 文件有什麽區別呢?