YAML系列:番外篇application.properties 改成 application.yml

作者:Damniel

郵箱:[email protected]

微博:

博客:https://blog.csdn.net/bulletoo_(轉載請說明出處)

---------------------------------------------------華麗的分割線----------------------------------------------------------------

前言

.yml文件格式是用YAML語音編寫的文件

YAML 是專門用來寫配置文件的語言,非常簡潔和強大,遠比 JSON 格式方便。

JSON是YAML 的子集,YAML是JSON的超集

原始application.properties文件內容:

server.port=8080  
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/amnotsherlockholmes  
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  

轉換成application.yml內容爲:

server:  
  port: 8080  
  session-timeout: 30  
  tomcat.max-threads: 0  
  tomcat.uri-encoding: UTF-8  
  
spring:  
  datasource:  
    url : jdbc:mysql://localhost:3306/amnotsherlockholmes  
    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 
十分方便閱讀和理解
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章