Skip to content

Why use reflect to access RedisProperties method? #4838

Answered by Milk-Bottle
Kicey asked this question in Q&A
Discussion options

You must be logged in to vote

The answer comes from chatGPT

The reason why reflection is used in RedissonAutoConfiguration to access the RedisProperties method instead of accessing it directly is because RedisProperties is an optional dependency in Redisson Spring Boot starter.

If RedisProperties is not present on the classpath, attempting to access it directly would result in a ClassNotFoundException. To avoid this issue, reflection is used to check whether RedisProperties is present, and only access it through reflection if it is available.

Here's the relevant code from RedissonAutoConfiguration:

`
private void configureSingleServerConfig(SingleServerConfig singleServerConfig, RedisProperties properties) throws Exce…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mrniko
Comment options

Answer selected by mrniko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants