Detailed explanation of spring boot static variable injection configuration file

This example shares the specific code of spring boot static variable injection configuration file for your reference. The specific contents are as follows

Spring static variable injection

Spring does not support direct injection of static variable values. Let's take a look at the code:

The configuration file is as follows:

Use the logbrokerlist variable when the project starts

Execution results:

terms of settlement

Use spring's set injection method to inject static variables through the non static setter method. We can change it so that the static variables can obtain your configuration information:

Execution results:

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>