What are the uses of spring boot citation ${} and @ @
This article mainly explains "what is the usage of spring boot citation ${} and @ @". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what is the usage of spring boot citation ${} and @ @"!
Both ${} and @ @ are ways in which springboot references property variables, which are different from the usage:
1. ${} is commonly used for property variable references in default configuration files such as pom.xml and src/main/resources/application.properties.
The syntax is: field_name=$ {field_value}
Pom.xml example:
2.7.0 org.apache.dubbo dubbo ${dubbo.version}
Application.properties example:
# logback Log configuration
Log.config.address=classpath:config/logback-spring.xml
Logging.config=$ {log.config.address}
2. @ @ is often used to refer to variables in springboot non-default configuration files (that is, other configuration files), where springboot is used instead of ${}
Attribute placeholders are generated because ${} is handled by maven, so references to non-default configuration files do not reference variables.
Syntax is: field_name=@field_value@
Example: in the actual project development, in order to test in different environments, we will create a config folder under the src/main/resources directory
And create multiple properties files in config, such as local.properties, development.properties, production.properties
When we refer to the properties of src/main/resources/config/local.properties in the src/main/resources/application.properties file
Variable, use the @ @ method
# Port configuration server.port=@server.port.web@ # logback log configuration logging.config=@logging.config@ here, I believe you have a better understanding of "what is the usage of spring boot reference ${} and @ @", you might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!