Personal brief introduction: New star creator in the Java field; Alibaba cloud technology blogger, star blogger, expert blogger; on the way of learning Java, recording the learning process~ Personal homepage: .29.'s blog
Learning community
: Go in and have a stroll~
SpringBoot - custom configuration file
SpringBoot's custom configuration file
The configuration file of the SpringBoot project, by default, the file name is application
, and the following three formats can be used as the configuration file of the SpringBoot project:
-
application.properties
-
application.yml
-
application.yaml
-
自定义配置文件:
In the SpringBoot project configuration column in the IDEA development environmentProgram arguments
, specify the configuration file name by setting temporary properties, and identify the custom-named properties, yml, and yaml format files as SpringBoot configuration files:
--spring.config.name=MyApplication #配置文件名
--spring.config.location=classpath:/Myapplication.yml #配置文件类路径、全路径
,
If you want to configure multiple attributes in the above way, use separators between multiple attribute values .- The name of the configuration file can be modified by setting the startup parameters
- The configuration file can modify the path by setting the startup parameters
- Configuration files in microservice development are dynamically configured through the configuration center (SpringCloud technology)
Custom configuration file:重要说明
- Single-server projects: The need to use custom configuration files is low.
- Multi-server projects: There is a high demand for custom configuration files, and all configurations are placed in one directory for unified management.
- Based on SpringCloud technology, all servers will no longer set configuration files, but set them through the configuration center and dynamically load configuration information.