SpringBoot series: two, SpringBoot profile

SpringBoot configuration files in the resources folder

 

 

springboot profile supports two forms of writing, one is the classic properties and the other is yml

yml to represent the hierarchy of objects through space in the form of indented to the example used here yml way, if you previously wrote k8s container file, then it would be easier to get started

First put the file encoding format is set to UTF-8 or will Chinese garbled

 

 

Change the configuration file suffix yml, then write the configuration file

server: port can be set springboot start port

 

 

 Then we declare several properties in the controller to come and collect configuration values ​​file, and then outputs it through Action

 

 Start springboot call about interfaces see value

 

 

 

The second method is to come and collect the contents of the configuration file from the entity classes

Define an entity class, marked @Component annotations and notes @ConfigurationProperties

prefix as the target configuration section

 

 

Class injection configuration in the controller, and can get directly to get the corresponding configuration 

 

Start a program call interface see the return value

 

 

Springboot the next chapter we talk about how to use the Filter

 

Guess you like

Origin www.cnblogs.com/Tassdar/p/11487382.html