In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
What this article shares to you is about the port alias of Rainbond. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
Today, I'd like to introduce a little trick of Rainbond-port aliases.
The port alias, as the name implies, defines an alias for the component port.
Settings for port aliases
When you go to the port management page, click use alias to set the alias of the port, as shown in the following figure:
The role of port aliases
When a port alias is defined, Rainbond generates two external environment variables for the alias: the port alias _ HOST and the port alias _ PORT. For example, if the port alias is MYSQL, the corresponding environment variables are MYSQL_HOST and MYSQL_HOST.
I don't know if you have noticed that these two environment variables are actually the access method of the port. Access method = port alias _ HOST: port alias _ PORT. For example, the port alias is MYSQL, and the corresponding access method is MYSQL_HOST:MYSQL_PORT, that is, 127.0.0.1 3306.
Another important point is that the port alias _ HOST can be sensed regardless of the change in the governance mode of the application to which the component belongs.
In other words, as long as the component that needs to access the port depends on the component, you can easily know its access method; no matter how the governance mode of the application changes, the access method will change accordingly and remain correct all the time.
Spring components connect to MySQL
To further illustrate, let's take a Spring component to connect to MySQL as an example to see how Spring can easily get access to MySQL.
Those of you who are familiar with Spring may know that its configuration file can look like this:
Spring.jpa.hibernate.ddl-auto=updatespring.datasource.url=jdbc:mysql://$ {MYSQL_HOST:localhost}: ${MYSQL_PORT:localhost} / db_examplespring.datasource.username=springuserspring.datasource.password=ThePassword
Maybe some students are not familiar with Spring, but it doesn't matter. All we need to know is that Spring uses environment variables to render variables in the configuration file.
As long as the Spring component relies on the MySQL component, Rainbond injects the external environment variables of the MySQL component into the Spring component.
In other words, after the Spring component relies on MySQL, it automatically gets the environment variables MYSQL_HOST and MYSQL_HOST. If MYSQL_HOST=127.0.0.1, MYSQL_PORT=3306, after Spring rendering, the link address of the database becomes spring.datasource.url=jdbc:mysql://127.0.0. 1:3306/db_example, so that you can access the MySQL components correctly.
Port alias is a very convenient function in the communication between Rainbond components. By setting an alias for the port, you can easily get the access mode of the port. Rainbond cloud native application management platform to achieve micro-service architecture without changing the code, managing Kubernetes without learning containers, helping enterprises to implement applications on the cloud, and continuously delivering any enterprise applications to Kubernetes clusters, hybrid clouds, multi-clouds and other infrastructure. It is the supporting platform of Rainstore cloud native application store.
The above is what the port alias of Rainbond is, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.