1.properties mode
Dev Test prod developing and testing production environment data
Multi-profile file
Default Application.properties
You can switch the environment:
Spring.profiles.active=dev
2.YML mode
YML supports multi-document block environments
YAML uses---to "split" a document into multiple documents
#yaml文档块模式server: 8081 Spring: profiles: activemq:dev---server: 8083Spring: Profiles: Dev---server: 8084Spring: profiles:prod
3 How to modify the command line in real time:
--spring.profiles.active=prod
You can do it, don't write it wrong.
Or package, go to the Jar package directory, cmd command line startup Project command is the following:
Java-jar Spring-boot-02-config-0.0.1-snapshot.jar--spring.profiles.active=prod
Or use the virtual machine parameters
-dspring.profiles.active=dev
Configuration file Drop Location
Scan: The config directory under the current project file:/config/, the file path of the current project file:./, the config inside the classpath classpath:/config/, the root directory of the classpath classpath:/
Scan in sequence with priority high to low, duplicate configuration is overwritten by high priority, non-duplicated configuration complements
As below, the Classpath under config is higher than./Medium priority
The Config directory has the highest priority under the project path
When the following method is only applicable to operations, you can use command line arguments to specify a new location for the configuration file that complements the default profile.
Spring.config.location=g:\application.properties
The command line can also be teminal in the lower left corner of the portal, suitable for operations when a small number of new configurations are added without repackaging in the run project
7.springboot configuration file Configuration Run environment, drop location