Springboot's two configuration file syntax || configuration file placeholder || @Value read configuration file and verify processing

[Master] Two configuration file syntaxes of springboot



Import the package automatically prompted by the configuration file



Create Student class



Create and modify application.properties





Profile placeholder

$ {random.int}   generates an int random number

$ {random.value}   generates a random string

$ {random.long}   generates a long random data

$ {random.int (10)}    generates 0-10 random int numbers

$ {random.int [10,100]}    Random int number from 10 to 100

$ {sutudent.name}  reads the name property in the student object in the ioc container





Description of the two grammars

Properties have no hierarchical relationship using = assignment

Yml has a hierarchical relationship Use: Assignment

The configuration of the two grammars is complementary



@Value read configuration file and verify processing

@Value read configuration file

Fact sheet

1. If the configuration is written in properties,    only the Map cannot be obtained

2. If the configuration is written in the yml      array collection, you can't get it

3 , if the attribute is using camel case nomenclature , you   cannot use attribute name injection ,

        To use @Value ("$ {student.user-name}") to get the value

       Cannot use @Value ("$ {student.userName}") to get the value



Published 529 original articles · praised 115 · 90,000 views

Guess you like

Origin blog.csdn.net/qq_39368007/article/details/105604509