spring boot配置文件:application.yml (yml与properties文件优缺对比)
2017-11-19 11:47
656 查看
现在我们的application.properties文件内容是:
[plain] view
plain copy
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内容:
[plain] view
plain copy
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
[plain] view
plain copy
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内容:
[plain] view
plain copy
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
相关文章推荐
- spring boot 读取配置文件(application.yml)中的属性值
- SpringBoot配置文件application.yml (application.properties)
- Spring Boot中配置文件application.properties使用
- spring boot 读取配置文件(application.yml)中的属性值
- Spring Boot 配置文件application.yml
- application.properties/application.yml文件中配置项
- spring boot更改配置文件 application.properties的位置
- 【springboot】Spring boot配置文件 application.properties
- spring boot 读取配置文件(application.yml)中的属性值
- Spring Boot - 配置文件 application.properties 配置参考
- Spring boot配置文件 application.properties
- Spring Boot配置文件 application.properties
- spring boot-application.properties配置文件属性
- spring boot 读取配置文件(application.yml)中的属性值
- 错误--spring boot的application.yml配置文件报错
- Spring Boot配置文件 application.properties
- SpringBoot属性文件配置(application.properties/yml)
- SpringBoot学习:获取yml和properties配置文件的内容
- Spring Cloud配置文件yml与properties
- SpringBoot学习:获取yml和properties配置文件的内容