In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces what is the difference between yml and properties in springboot. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
Properties files need to be fully written, yml before the same can not be written, one layer corresponding to one layer is good.
By comparison:
Application.properties
Application.yml
There are some details to pay attention to in the yml file. The colon should be followed by a space before writing the value, although it will automatically be empty in the IDE.
What's the difference between an application.properties file and an application.yml file?
The benefits of yml files, the natural tree structure, are clear at a glance and are essentially similar to properties.
Many of the official demo are configured with yml files.
Note:
1. The original key, such as spring.jpa.properties.hibernate.dialect, press "." Split into tree-like configurations
The colon after the key must be followed by a space.
3. Delete the original application.properties. Then be sure to execute maven-X clean install
# application.ymlserver: port: 8086 spring: datasource: name: test url: jdbc:mysql://192.168.1.112:3306/test username: root password: xxx # use druid data source 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 applications. Propertiesserver.portalization8085spring.datasource.typeroomorg.apache.tomcat.jdbc.pool.DataSourcespring.datasource.urlroomjdbcjdbcdisplacement mysqldebartaliyuncs.compur3306Universe Unicodecodes trueworthy DateTimeBehaviorholders convertToNullroomautonectparts truespring.datasceour.usernameroomrootspring.datasource.passwordcards Class-name=com.mysql.jdbc.Driver#mybatis.mapper-locations=classpath*:com/wanyu/fams/mapping/*Mapper.xml#mybatis.type-aliases-package=com.wanyu.fams.modelspring.mvc.view.prefix=/WEB-INF/jsp/spring.mvc.view.suffix=.jspspring.druid.datasource.type=com.alibaba.druid.pool.DruidDataSourcespring.druid.datasource.driverClassName=com.mysql.jdbc.Driverspring.druid.datasource.url=jdbc:mysql://localhost:3306/spring_boot?characterEncoding=utf-8spring.druid.datasource.username=rootspring.druid.datasource.password=xxx
Although Spring Boot has done a lot of work to simplify the configuration, but its configuration is still quite complex!
As many as 17 external configurations are supported, which is flexible, of course, but flexibility means increased complexity.
Here we only talk about the priority of application.yml and application.properties files.
If there is an application.properties file in your project
Then the application.yml file is just a device.
Why would you say that?
I configured this in the application.properties file:
Server.port=8085
The following are configured in the application.yml file:
Server:
Port: 8086
Start the project, console output:
Main] s.b.c.e.t.TomcatEmbeddedServletContainer: Tomcat started on port (s): 8085 (http)
Fully illustrates this point.
This is the difference between yml and properties in springboot. I hope the above content can be helpful to everyone and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.