Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of installing MyBatis source code

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "the method of installing MyBatis source code". In the daily operation, I believe that many people have doubts about the method of installing MyBatis source code. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "MyBatis source code installation method". Next, please follow the editor to study!

The disadvantages of traditional JDBC

1. Connection pooling is not used at the bottom of jdbc, and frequent creation and association links are required to operate the database. Consume a lot of resources

2. Write native jdbc code in java. Once we want to modify sql, java needs to be compiled as a whole, which is not conducive to system maintenance.

3. Set 123digits to the variables using PreparedStatement precompilation, which is not good for maintenance.

4. Returning the result result set also requires hard coding.

Core concepts of mybatis

Configuration 、 SqlSessionFactory 、 Session 、 Executor 、 MappedStatement 、 StatementHandler 、 ResultSetHandler

The name meaning Configuration management mysql-config.xml global configuration relationship class SqlSessionFactorySession management factory interface SessionSqlSession is an interface for users (programmers). SqlSession provides many methods to manipulate the database, Executor.

An actuator is an interface (basic actuator, cache actuator)

Function: SqlSession operates the database internally through the executor

MappedStatement

Underlying encapsulated object

Function: store and encapsulate the operation database, including sql statements, input and output parameters

StatementHandler specific operation database related handler interface ResultSetHandler specific operation database return result handler interface

Source code compilation and download

Https://github.com/mybatis/mybatis-3

Https://github.com/mybatis/parent (dependent)

It can be imported directly into idea or downloaded directly as a zip package (recommended).

The Mybatis source code attacks the parent project. You need to compile the parent project before compiling mybatis, as follows

Resolve parent dependency issues:

During the build process, the parent module mybatis-parent, which cannot be found in pom.xml, will appear.

We need to clone the paren project to the local directory: git clone https://github.com/mybatis/parent.git, and then go to the parent project to mvn clean install to download the package that the parent project depends on, and ensure that the parent project is compiled. There will be no problem in this step. In the compiled output information, we will see the version number of the parent project, as shown in the figure:

The version tag that the pom.xml file parent depends on, as shown below.

Next, modify the places where parent is identified in the pom.xml file of the mybatis project:

Org.mybatis mybatis-parent 28-SNAPSHOT.. / parent/pom.xml

Tell us that some plug-ins do not have the corresponding version number specified, for the sake of the stability of the project, we need to specify the version number of the plug-in, and give the appropriate version number, such as the text in the red box. We just need to add the $NUM tag in the pom.xml file of the mybatisg project to find the corresponding plug-in, and $NUM represents the specific version number. At this point, we can successfully build the mybatis project by executing the mvn clean install instruction.

At this point, the study of "the method of installing MyBatis source code" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report