First, the configuration
Resources under Application.properties
1. General Configuration
Resources under Application.properties, such as write: server.port=9090, then the boot port is 9090
2. Custom Configuration
3. Reference to configuration variables
4, Random value configuration: If the parameters are random, you can be in the configuration file with
5, Random port configuration: To avoid port conflict problems
#server. Port=9090 server.port =${random. int [1024 , 9999 ]}// random port gwf.num=${random. int }// random number Gwf.hello=hello// Gwf.name = GWF ${gwf.hello} ${gwf.num}// reference to configuration variable
@RestController Public class Hellocontroller { @Value ("${gwf.name}") private String msg; @RequestMapping ("/hello") public String Hello () { returnthis. msg; }}
Use is referred to by the annotation @Value ("${}"), which is somewhat analogous to the way in which a JSP variable is evaluated
Second, yml configuration file
Yaml is a language for writing configuration files, it is a natural tree structure
Third, log configuration file
Logback.xml, can Baidu query
Four, multi-environment configuration
Application-{profile}.properties,profile represents an environment variable
After packaging, go to the jar store directory and execute the command:
Java-jar ***.jar--spring.profilr.active=dev/test, performing the development environment and test environment respectively
Spring Boot Basics: Configuration file configuration variables