Introduction and use of mybatis

Table of contents

1. Commonly used architecture:

2. Mybatis

Three, mybatis creation steps:


1. Commonly used architecture:

Common architectures for software development:

Three-tier architecture:

Interface layer (view layer, presentation layer): directly associated with users (such as jsp, html, servlet)

Business logic layer: receives the data passed by the interface layer, checks the data, and calculates business logic. Call the data access layer to obtain data (such as service)

Data access layer: implements additions, deletions, modifications and queries to the database, hands the data stored in the database to the business layer, and saves the data processed by the business layer to the database

Framework: equivalent to a template. Some available functions have been defined in it, and we only need to add the functions we need.

2. Mybatis

Mybatis is equivalent to a mature version of jdbc, a SQL mapping framework

Sql mapper: sql mapping (maps a row of data in the database into a java object, operating this java object is equivalent to operating the data in the table)

Data access objects (DAOS): data access (add, delete, modify and check the database)

Mybatis function:

Three, mybatis creation steps:

1. First create a maven project

Create an empty project (it is said to be just a default rule, you can also create a maven project directly from the beginning):

Give your project a name and click finish

Then modules will pop up. If they do not pop up or are forked, you can open them yourself.

Later, you can create a maven project based on the prototype. The structure of different projects is slightly different, and you can choose according to your own needs.

This is just a reference

groupid: organization name, usually the company domain name flashback plus the project name

artifactld: module name, usually project name

version: version number, generally unchanged by default

Then in the pop-up box in the lower right corner, click Auto Import

 

Four, supplement

1. Create a project through prototype in maven: 

To perform simple database access operations, you can use quickstart without web applications.

(Hey, I don’t quite understand it either. I’ll add more when I learn about this later)

2. maven’s .m2 folder:

Default warehouse repository:

The default warehouse location after resource downloading is: C:\Users\86178\.m2\repository (the content downloaded after being connected to the Internet will be stored there)

The specific content can be viewed from maven.

After installing and configuring maven, it is found that the .m2 folder does not exist in the directory . The reason is that no maven-related commands have been executed. Maven will automatically create the .m2 folder after execution.

Under cmd: mvn help:system command will automatically create .m2 file

Guess you like

Origin blog.csdn.net/m0_58115520/article/details/123464409