There are many ways to find @value in the project
The role of @value injection:
The external values are injected dynamically into the bean by @value.
1, can inject ordinary string
2. Inject operating System Properties
3. Inject expression results
4. Inject Other bean properties
5. Inject File Resources
6. Inject URL Resources
@value ("Nomalchacter")
Private String char;//Inject ordinary characters
@value ("#{sytemproperties[' Os.name '}")
Private String systempropertiesname;//injected into the operating system
@value ("#{t (Java.lang.Math). Random () *100.0}")
Private double randomnumber;//injection expression result
@Value ("#{bean.name}")
Private String Fromanotherbean; Inject other bean properties: Inject the properties of the Beaninject object name
@Value ("Classpath:com/1.txt")
Private Resource resourcefile; Inject File Resources
@Value ("http://www.gogle.com")
Private Resource Testurl; Inject URL Resource
The value of the property file is injected into the Bean property value by @value ("${app.name}") syntax.
@Value ("${person.name}")
private String name;
@Value ("${person.name.firstname}")
Private String firstname;//injected with name FirstName
There are #{} and ¥{} in the above usage, what is the difference between them?
#{..} Primarily used to execute Spel expressions and assign content to properties
${..} Used primarily to load values from an external properties file
#{..} and ${...} Can be mixed, but must #{} outside, ${} in it