Home > Back-end >  Spring comments @ Value and what is the difference between direct assignment?
Spring comments @ Value and what is the difference between direct assignment?

Time:03-12

Today suddenly found annotated assignment of spring, in the heart is a bit confusing but baidu no answers, bosses, genuflect is begged solve, the in the mind a little entanglements,
@ Value (" 1 ")
Int num.
And
Int num=1;
What is the difference? Or where the meaning of the annotation assignment,
Kneeling for

CodePudding user response:

Family values from the config file, change the data, do not change the code

CodePudding user response:

Springboot project, @ the Value read from the Value of the yml configuration file as a

CodePudding user response:

Main or can be read from the configuration data, if the "1" is a special variable, if you are used to more than 1, 100 in your code you are about to change in 100, and reading configuration only need to change the configuration file

CodePudding user response:

Should not like you to use, a configuration class attribute in the configuration file is needed, it is similar to the following this with
@ Value (" ${catalog. The name} "))
  • Related