The difference between Springboot's application.properties and. yml

Source: Internet
Author: User

Now our Application.properties file content is:

[Plain]View Plain Copy
  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


Many of the official demos are configured with YML files.

YML file benefits, natural tree-like structure, at a glance. But it was painful to change application.properties to APPLICATION.YML.

Here is the APPLICATION.YML content after replacement:

[Plain]View Plain Copy
  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


Note the point:

1, the original key, such as Spring.jpa.properties.hibernate.dialect, press "." Split, all into a tree-like configuration

2,key after the colon, must follow a space

3, delete the original application.properties. Then be sure to execute the maven-x clean install

Springboot's application.properties differs from the. Yml

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.