Spring and mybatis integrate redis based on annotations

Based on this period of time, redis has encountered various problems and wants to sort it out. This paper mainly introduces the integration of redis in the form of annotations based on Spring + mybatis. Cut the crap and get to the point.

First, prepare redis. I download the Windows version. After downloading, just start redis server directly, as shown in the figure below:

1、 Start with the jar package

2、 Create entity class

3、 Dao interface

4、 Usermapper

5、 Service interface

6、 Service implementation

7、 CTRL layer

8、 Redis key class, used for crud operation

9、 Spring integrates mybatis and redis configuration files

10、 Spring MVC configuration file

11、 Mybatis configuration file

12、 Log4j

13、 Web xml

14、 Test. Take the query as an example (getuser () method). The JSP test page is ugly, so it won't be posted. Write one yourself...

Before query:

Execute the first query:

Perform the second query:

As can be seen from the figure above, no more SQL is executed and data is directly obtained from redis.

The above is the method of integrating spring and mybatis redis based on annotations introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>