Suppose I define some configuration in application.properties under classpath:

I want this configuration to be automatically injected into a variable in my Java code. The easiest way to do this is to use annotations @propertysource and annotation@Value. The following example is easy to understand:

@value (“${spring.redis. Host}”) automatically injects the Value of the configuration item in application.properties into the Java variable redisHost of type String.



For more of Jerry’s original articles, please follow the public account “Wang Zixi “: