notes
1, SpringBoot multi-environment configuration presentations and project combat (Core Knowledge)
Description: SpringBoot introduce multi-configuration environment and usage scenarios
1, different environments with different configurations
such as database configuration, at the time of development, we generally use to develop the database, but in a production environment , we are using the formal data
2, the configuration file storage path
classpath root directory "/ config" undercladding
the root of the classpath
3, spring boot allows the naming convention according to a certain format (application- {profile} .properties ) to define multiple profiles
Start
This is a relatively simple new empty project
different databases in different environments
built here three configuration files. We are under house ah config folder
development environment called the dev.com
test will be called test.com change
default test environment. test.url = local is the local environment
where the configuration of the test, it will find application-test.properties this profile.
Testing a Profile
Start the application
is currently testing environment
to switch to the dev environment
to restart the service
configuration file to comment
is not enabled, then the reading is application.properties the default configuration file
to start the test program