spring boot program reads the configuration file from maven pom.xml file content label.

Requirements: The pom.xml file version number in the configuration file to read and print the log.

Step one: Add the following tag in pom.xml.

  

 

 

Step two: the value of the version label to read the configuration file

 

As used herein, instead of $ @@} {because spring boot does not recognize the configuration file $ {} will cause an error symbol.

Step 3: If spring boot is configured in the default configuration file, then @Value annotations directly in the project by injecting value.

  If a custom configuration file, then use @PropertySource ( "classpath: fixed-config.properties") annotation to load custom configuration file, and then use the value can be injected @Value comment

 

Guess you like

Origin www.cnblogs.com/qiaoyutao/p/11541577.html