Loading order and differences between yml and properties:

1. First recommend an online conversion address:

      http://www.toyaml.com

 

2.File in yml format:

     Natural tree structure, the same prefix only needs to be written once.

server:

  port: 7081

spring:

  elasticsearch:

    Is:

      uris:

      - http://192.168.0.216:9200

      read-timeout: 5000

 

 

 

3.File in properties format:

    All the same prefixes need to be written every time.

server.port=7081

spring.elasticsearch.jest.uris[0]=http://192.168.0.216:9200

spring.elasticsearch.jest.read-timeout=5000

 

 

4. The loading order of the two

 

    The normal situation is to load the yml first and then the properties file. If the same configuration exists in both files. Finally, the configuration in properties will be used. The last read has the highest priority set.

   If the port numbers in the two configuration files are different, the port number in properties will be read.

 

 

5. The effect of putting different configurations into two configuration files:

        The same configuration is placed in two configuration files:    

 

Verification result: The program can be accessed normally.

 

6. The difference between the two:

What is the difference between application.properties files and application.yml files?

The advantage of yml files is that the natural tree structure is clear at a glance. It is essentially the same as properties.

Many official demos are configured using yml files.

important point:

1. The original keys, such as spring .jpa.properties. hibernate .dialect, are divided by "." and become a tree configuration.

2. 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

 

 

Learn from:

https://www.cnblogs.com/dyh-air/articles/9090882.html    

 

Guess you like

Origin blog.csdn.net/Tank_666/article/details/83859093