当前位置:网站首页>SSM assembly
SSM assembly
2022-07-06 02:15:00 【hjhcos】
List of articles
brief introduction
SSM The assembly is Spring + SpringMVC + MyBatis Integration of the framework , Divide the system into view layers 、 Control layer 、 Service layer 、 The data layer .
controller The controller will be used service service ;service The service will be used mapper Data mapping and converting data into domain Data objects ;mapper Data mapping will be used domain Define data types .
entity: Data objects , It can reduce the data processing process .
model: stay entity On the basis of improvement , Make the data more humanized .
domain: stay model Expand and integrate data sources based on , It can enrich data and diversify .
Controller registration
adopt @Controller and @RestController Annotations can automatically register the controller into the project , Pass again like this @RequestMapping Annotations can map requests , Generally, you can access pages or data .
By the way @RestController = @Controller + @ResponseBody, Its source code is basically the same .
The controller is scanned
When class is used @Controller To register the controller and be able to Spring Application scanning can be divided into two cases :
External dependencies are referenced into the project
You can probably understand that when the controller is not in the current project , But in the dependency package of the project , for example SpringSecurity Default login page , It is referenced through external modules .
And Spring Application startup class peer automatic scanning
spring-boot-starter-web
file :https://www.yiibai.com/spring-boot/spring-boot-starter-web.html
spring-boot-starter-web The integration package includes web、webmvc and tomcat .
therefore tomcat The server and Spring MVC The framework is automatically configured , Greatly reduce the amount of development .
If you want to configure the server yourself , Can also be spring-boot-starter-tomcat Exclude items from use tomcat The server .
mybatis-spring-boot-starter
mybatis-spring-boot-starter Integration package is right MyBatis + MyBatis-Spring + SpringBoot Integrated packaging of , Therefore, it is highly dependent , But it greatly reduces the amount of development , You don't have to configure SqlSessionFactory And transaction processing .
function
Automatically discover existing data sources
utilize SqlSessionFactoryBean Create and register SqlSessionFactory
Create and register SqlSessionTemplate
Automatic scanning Mapper, And register to the Spring Context environment facilitates the injection and use of programs
By default, it will find @Mapper Annotation marker mapper , In addition, you can actually pass @MapperScan Annotations to scan packages .
MyBatis
MyBatis Is an excellent persistence layer framework , It supports customization SQL、 Stored procedures and high-level mappings .MyBatis It dispenses with almost everything JDBC Code and the work of setting parameters and getting result sets .MyBatis It can be done by simple XML Or annotations to configure and map primitive types 、 Interface and Java POJO(Plain Old Java Objects, Ordinary old-fashioned Java object ) For records in the database .
SqlSession
SqlSessions By SqlSessionFactory Instance created .SqlSessionFactory Object contains create SqlSession Examples of various methods . and SqlSessionFactory Itself is made up of SqlSessionFactoryBuilder Created , It can come from XML、 Note or Java Configure code to create SqlSessionFactory.
XML mapper
The element tag
| label | describe |
|---|---|
| cache | Cache configuration of namespace |
| cache-ref | Cache configuration referring to other namespace |
| resultMap | Describes how to load objects from a database result set |
| sql | sql sentence , A block of repeatable terms that can be referenced by other statements |
| insert | Mapping insert statements |
| update | Mapping update statements |
| delete | Mapping delete statements |
| select | Mapping query statements |
Element attributes
| attribute | value | The default value is | scene | describe |
|---|---|---|---|---|
| id | string | —— | [select | update |
| parameterType | object | unset | [select | update |
| resultType | object | —— | [select | update |
| resultMap | object | —— | [select | update |
| flushCache | boolean | false | [select | update |
| useCache | boolean | true | select | If this statement is called, the result will be cached by the L2 cache . |
| timeout | int | unset | [select | update |
| fetchSize | int | unset | [select | update |
| resultOrdered | boolean | false | [select] | If true, It is assumed that nested result sets or groups are included , When a main result row is returned , There is no reference to the previous result set . This makes it possible to get nested result sets without running out of memory . |
| resultSets | [object…] | —— | [select] | This setting only applies to multiple result sets . It will list the result sets returned after the statement is executed and give each result set a name , Multiple names are separated by commas . |
| useGeneratedKeys | boolean | false | [insert | update] |
| keyProperty | string | unset | [insert | update] |
| keyColumn | string | —— | [insert | update] |
\
边栏推荐
- MySQL lethal serial question 1 -- are you familiar with MySQL transactions?
- Redis daemon cannot stop the solution
- 使用npm发布自己开发的工具包笔记
- Computer graduation design PHP campus restaurant online ordering system
- Grabbing and sorting out external articles -- status bar [4]
- 02. Go language development environment configuration
- Comments on flowable source code (XXXV) timer activation process definition processor, process instance migration job processor
- 【clickhouse】ClickHouse Practice in EOI
- Minecraft 1.16.5 biochemical 8 module version 2.0 storybook + more guns
- MySQL index
猜你喜欢

Minecraft 1.16.5 生化8 模组 2.0版本 故事书+更多枪械

Minecraft 1.16.5 biochemical 8 module version 2.0 storybook + more guns

论文笔记: 图神经网络 GAT

Know MySQL database

2022 edition illustrated network pdf

Executing two identical SQL statements in the same sqlsession will result in different total numbers
![[width first search] Ji Suan Ke: Suan tou Jun goes home (BFS with conditions)](/img/ec/7fcdcbd9c92924e765d420f7c71836.jpg)
[width first search] Ji Suan Ke: Suan tou Jun goes home (BFS with conditions)

selenium 等待方式
![[flask] official tutorial -part2: Blueprint - view, template, static file](/img/bd/a736d45d7154119e75428f227af202.png)
[flask] official tutorial -part2: Blueprint - view, template, static file
![抓包整理外篇——————状态栏[ 四]](/img/1e/2d44f36339ac796618cd571aca5556.png)
抓包整理外篇——————状态栏[ 四]
随机推荐
It's wrong to install PHP zbarcode extension. I don't know if any God can help me solve it. 7.3 for PHP environment
2022年版图解网络PDF
Sword finger offer 12 Path in matrix
Kubernetes stateless application expansion and contraction capacity
RDD creation method of spark
Redis string type
Adapter-a technology of adaptive pre training continuous learning
2022 PMP project management examination agile knowledge points (8)
Minecraft 1.18.1, 1.18.2 module development 22 Sniper rifle
Thinking about the best practice of dynamics 365 development collaboration
VIM usage guide
National intangible cultural heritage inheritor HD Wang's shadow digital collection of "Four Beauties" made an amazing debut!
Global and Chinese market of commercial cheese crushers 2022-2028: Research Report on technology, participants, trends, market size and share
【clickhouse】ClickHouse Practice in EOI
The intelligent material transmission system of the 6th National Games of the Blue Bridge Cup
sql表名作为参数传递
2022年PMP项目管理考试敏捷知识点(8)
Visualstudio2019 compilation configuration lastools-v2.0.0 under win10 system
This time, thoroughly understand the deep copy
SSM 程序集