Spring integration of Mybatis development ideas

Integrated thinking

Both Spring and Mybatis are frameworks. Should Mybatis take over Spring or Spring take over Mybatis?

Through early learning, we know that Mybatis framework is a persistence layer ORM framework, and the Spring we are learning today is a comprehensive framework. So the integration is the integration of Mybatis to Spring. It is to let the Spring framework take over the creation of the SqlSessionFactory factory in Mybatis, and at the same time create the proxy implementation class of dao by reading the mapper configuration content, and store them all in the IoC container.

Both Spring and Mybatis have independent configuration files. When we integrate, we have two choices. The first is to keep the configuration files of the two frameworks, and the second is to keep only the Spring configuration files, and write all the Mybatis-related configurations in the Spring configuration files.

The result of these two methods is that the second one looks more concise and clear.

Guess you like

Origin blog.csdn.net/weixin_47785112/article/details/107387265