1. Integrate MyBatis
1.1. Introduce maven dependencies
1.2. Generate Mapper
For details, please refer to the official website of MyBatis Generator
http://www.mybatis.org/generator/running/running.html
Here is the maven method
First, create a configuration file
Next, introduce the maven plugin
Finally, the command line runs the command
1.3, configuration
2. Integrate Redis
2.1. Introduce maven dependencies
2.2, configuration
That's it, the most concise configuration is like this , and then you can use StringRedisTemplate
2.3. Examples
3、Redis Cache
3.1. Introduce maven dependencies
3.2, configuration
3.3. Why do you only need to configure as above?
The above configuration is the simplest and most concise configuration (PS: customization is not considered here), why is this configuration possible? Because that's what the official website says.
3.4. Examples
3.5. Custom Value serialization
Using the default configuration as above can look good, but there is a problem: the value stored in redis is in binary form, which is not conducive to viewing
It would be nice if it were a JSON string. For this we need to customize SerializationPair
So, how to customize it? The official documentation is very clear
Next, we customize a RedisCacheConfiguraion
So, everything is different
So far, the perfect job! There is applause here, give yourself a like! ! !
4. Attach the rest of the code screenshots
5. Supplement: Spring Cache related understanding
https://docs.spring.io/spring/docs/5.0.5.RELEASE/spring-framework-reference/integration.html#cache-annotations-evict
The official documents are written more clearly, there are too many content, not screenshots one by one, everyone has time to see it for yourself! ! !
Finally, if you think this article is okay, please don't be shy and like it! (✺ω✺)(✺ω✺)(✺ω✺)