Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the uses of spring boot citation ${} and @ @

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report