SOFABoot is a middleware solution built on Spring Boot. It follows the same configuration file reading logic as Spring Boot, using the application.properties file to implement global configuration.
Configuration type
Key-value pairs in application.properties are mainly divided into the following two types:
System Configurations: Key-value pairs defined by the SOFABoot framework that control framework behavior. View all system configuration items under properties-system.
Custom Configurations: Key-value pairs defined and used by developers in application code. These configurations do not affect the SOFABoot framework; their semantics and usage are entirely determined by users.
Default configuration
properties file path:
resources/config/application.propertiesThe requirements for the storage path of the properties file are:
In a standard Maven project, the configuration file must be stored in the preceding path to ensure that the application packages the file into the final JAR or War package.
When running in the IDE, you also need to ensure that the files are loaded correctly into the
classpath.
Properties main default parameters
spring.application.name={APPNAME} logging.level.com.alipay.sofa=INFO logging.path=./logs ...
Default parameter description
The default application.properties contains the following three parameters:
spring.application.name
cannot be deleted.
Application name characters can contain only lowercase letters a to z and hyphens (-).
The name of the application. The name must be unique. The SOFABoot framework and some middleware use this configuration value as the name of the application. This configuration uses the artifactId specified when you create the project as the default value. During RPC calls and message delivery, the framework prints the application name in the framework log and also passes it in the context. If the name is the same, the logs of different applications cannot be distinguished during monitoring and service governance. In addition, the application code can also use this value to make some business logic judgment or identification distinction related to the application name.
logging.level.com.alipay.sofa=INFO is used to set the log level of the current application. The values can be:
INFO: the default value, which indicates the basic information log.WARN: indicates a warning log.DEBUG: indicates a debug log.
logging.path=./logs is used to specify the log output directory of the SOFABoot framework and each middleware.
Default value:
./logs. We recommend that you do not change this value.When run time locally, logs are exported to the logs directory of the root directory of the project.
When run time under Linux/OS X, the technology stack will switch to the admin user to run the program, and the log file will be output to the
/home/admin/logsdirectory.
Dynamically modify the configuration values of properties
application.properties: All configured settings are supported, but cannot be dynamically specified. Once the key-value in the file is hard-coded, it cannot be changed.You can use
java -Dto dynamically set parameters: For workspace-related configurations and other parameters that need to be dynamically set, SOFABoot supports using-Dparameters to dynamically set values. This configuration mode has the following advantages:Dynamic adjustment can be achieved.
Has a higher priority: If the key in the
application.propertiesconflicts with the key of the-Dparameter, the value of the-Dparameter takes effect.Flexible deployment can be achieved by overriding or modifying hard-coded configurations with
-Ddynamics.
The configuration example is as follows:
java -Dparam1=value2 -Dparam2=value2
The priority of the properties configuration file. You can refer to the Externalized Configuration in the Spring Boot Reference Guide.
For more information
If you need to provide different configurations in different workspaces, such as development, testing, pre-release, and production workspaces, see Technology stack user guide.