22
33## 基本介绍
44
5- 框架是一款半成品软件,我们可以基于这个半成品软件继续开发,来完成我们个性化的需求!
6-
7- ORM(Object Relational Mapping): 对象关系映射
8- 指的是持久化数据和实体对象的映射模式,解决面向对象与关系型数据库存在的互不匹配的现象
5+ ORM(Object Relational Mapping): 对象关系映射,指的是持久化数据和实体对象的映射模式,解决面向对象与关系型数据库存在的互不匹配的现象
96
107![ ] ( https://gitee.com/seazean/images/raw/master/Frame/ORM介绍.png )
118
@@ -4191,9 +4188,9 @@ private UserDao userDao;
41914188
41924189相关属性:
41934190
4194- - required:为 true (默认)表示注入 bean 时该 bean 必须存在,不然就会注入失败;为 true 表示注入 false 时该 bean 存在就注入,不存在就忽略跳过
4191+ - required:为 true (默认)表示注入 bean 时该 bean 必须存在,不然就会注入失败;为 false 表示注入时该 bean 存在就注入,不存在就忽略跳过
41954192
4196- 注意:在使用 @Autowired 时,首先在容器中查询对应类型的 bean,如果查询结果刚好为一个,就将该 bean 装配给 @Autowired 指定的数据,如果查询的结果不止一个,那么 @Autowired 会根据名称来查找。如果查询的结果为空,那么会抛出异常。解决方法:使用 required = false
4193+ 注意:在使用 @Autowired 时,首先在容器中查询对应类型的 bean,如果查询结果刚好为一个,就将该 bean 装配给 @Autowired 指定的数据,如果查询的结果不止一个,那么 @Autowired 会根据名称来查找。如果查询的结果为空,那么会抛出异常。解决方法:使用 required = false
41974194
41984195
41994196
@@ -4570,7 +4567,7 @@ UserService userService = (UserService)bf.getBean("userService");
45704567
45714568FactoryBean与 BeanFactory 区别:
45724569
4573- - FactoryBean:封装单个 bean 的创建过程
4570+ - FactoryBean:封装单个 bean 的创建过程,就是工厂的 Bean
45744571
45754572- BeanFactory:Spring 容器顶层接口,定义了 bean 相关的获取操作
45764573
@@ -6533,23 +6530,23 @@ MySQL InnoDB 存储引擎的默认支持的隔离级别是 **REPEATABLE-READ(
65336530 }
65346531 ```
65356532
6536- **支持当前事务的情况:**
6533+ **支持当前事务**的情况:
65376534
6538- * TransactionDefinition.PROPAGATION_REQUIRED: 如果当前存在事务,则加入该事务 ;如果当前没有事务,则创建一个新的事务
6535+ * TransactionDefinition.PROPAGATION_REQUIRED: 如果当前存在事务,则**加入该事务** ;如果当前没有事务,则创建一个新的事务
65396536 * 内外层是相同的事务
65406537 * 在 aMethod 或者在 bMethod 内的任何地方出现异常,事务都会被回滚
6541- * TransactionDefinition.PROPAGATION_SUPPORTS: 如果当前存在事务,则加入该事务 ;如果当前没有事务,则以非事务的方式继续运行
6542- * TransactionDefinition.PROPAGATION_MANDATORY: 如果当前存在事务,则加入该事务 ;如果当前没有事务,则抛出异常
6538+ * TransactionDefinition.PROPAGATION_SUPPORTS: 如果当前存在事务,则**加入该事务** ;如果当前没有事务,则以非事务的方式继续运行
6539+ * TransactionDefinition.PROPAGATION_MANDATORY: 如果当前存在事务,则**加入该事务** ;如果当前没有事务,则抛出异常
65436540
6544- **不支持当前事务的情况:**
6541+ **不支持当前事务**的情况:
65456542
65466543- TransactionDefinition.PROPAGATION_REQUIRES_NEW: 创建一个新的事务,如果当前存在事务,则把当前事务挂起。
65476544 - 内外层是不同的事务,如果 bMethod 已经提交,如果 aMethod 失败回滚 ,bMethod 不会回滚
65486545 - 如果 bMethod 失败回滚,ServiceB 抛出的异常被 ServiceA 捕获,如果 B 抛出的异常是 A 会回滚的异常,aMethod 事务需要回滚,否则仍然可以提交
6549- - TransactionDefinition.PROPAGATION_NOT_SUPPORTED: 以非事务方式运行,如果当前存在事务,则把当前事务挂起
6550- - TransactionDefinition.PROPAGATION_NEVER: 以非事务方式运行,如果当前存在事务,则抛出异常
6546+ - TransactionDefinition.PROPAGATION_NOT_SUPPORTED: ** 以非事务方式运行** ,如果当前存在事务,则把当前事务挂起
6547+ - TransactionDefinition.PROPAGATION_NEVER: ** 以非事务方式运行** ,如果当前存在事务,则抛出异常
65516548
6552- ** 其他情况:**
6549+ 其他情况:
65536550
65546551* TransactionDefinition.PROPAGATION_NESTED: 如果当前存在事务,则创建一个事务作为当前事务的嵌套事务来运行;如果当前没有事务,则该取值等价于 PROPAGATION_REQUIRED
65556552 * 如果 ServiceB 异常回滚,可以通过 try-catch 机制执行 ServiceC
@@ -12773,36 +12770,6 @@ jsp:
1277312770
1277412771## XML
1277512772
12776- ### 整合流程
12777-
12778- 整合步骤分析:
12779-
12780- SSM (Spring + SpringMVC + MyBatis )
12781-
12782- * Spring :框架基础
12783-
12784- * MyBatis :mysql+ druid+ pagehelper
12785-
12786- * Spring 整合 MyBatis
12787-
12788- * junit 测试业务层接口
12789-
12790- * SpringMVC
12791- * rest 风格(postman 测试请求结果)
12792- * 数据封装 json(jackson)
12793-
12794- * Spring 整合 SpringMVC
12795-
12796- * Controller 调用 Service
12797-
12798- * 其他
12799-
12800- * 表现层数据封装
12801-
12802- * 自定义异常
12803-
12804-
12805-
1280612773### 结构搭建
1280712774
1280812775* 创建项目,组织项目结构,创建包
@@ -13088,13 +13055,7 @@ SSM(Spring+SpringMVC+MyBatis)
1308813055 < ? xml version= " 1.0" encoding= " UTF-8" ? >
1308913056 < beans xmlns= " http://www.springframework.org/schema/beans"
1309013057 xmlns: context= " http://www.springframework.org/schema/context"
13091- xmlns: mvc= " http://www.springframework.org/schema/mvc"
13092- xmlns: xsi= " http://www.w3.org/2001/XMLSchema-instance"
1309313058 xsi: schemaLocation= "
13094- http://www.springframework.org/schema/beans
13095- http://www.springframework.org/schema/beans/spring-beans.xsd
13096- http://www.springframework.org/schema/mvc
13097- http://www.springframework.org/schema/mvc/spring-mvc.xsd
1309813059 http://www.springframework.org/schema/context
1309913060 http://www.springframework.org/schema/context/spring-context.xsd" >
1310013061 < ! -- 开启注解驱动,提供Controller 请求转发,json自动转换等功能-- >
@@ -13103,7 +13064,7 @@ SSM(Spring+SpringMVC+MyBatis)
1310313064 < context: component- scan base- package= " controller" / >
1310413065 < / beans>
1310513066 ```
13106-
13067+
1310713068* MyBatis 映射:resources.dao. UserDao . xml
1310813069
1310913070 ```xml
@@ -13145,21 +13106,15 @@ SSM(Spring+SpringMVC+MyBatis)
1314513106 < / mapper>
1314613107 ```
1314713108
13148- * Mybatis 核心配置 :resouces. applicationContext. xml
13109+ * Mybatis 核心配置 :resouces. applicationContext. xml
1314913110
1315013111 ```xml
1315113112 < ? xml version= " 1.0" encoding= " UTF-8" ? >
1315213113 < beans xmlns= " http://www.springframework.org/schema/beans"
1315313114 xmlns: context= " http://www.springframework.org/schema/context"
13154- xmlns: tx= " http://www.springframework.org/schema/tx"
13155- xmlns: xsi= " http://www.w3.org/2001/XMLSchema-instance"
1315613115 xsi: schemaLocation= "
13157- http://www.springframework.org/schema/beans
13158- http://www.springframework.org/schema/beans/spring-beans.xsd
1315913116 http://www.springframework.org/schema/context
13160- http://www.springframework.org/schema/context/spring-context.xsd
13161- http://www.springframework.org/schema/tx
13162- http://www.springframework.org/schema/tx/spring-tx.xsd" >
13117+ http://www.springframework.org/schema/context/spring-context.xsdd" >
1316313118 < ! -- 开启bean-- >
1316413119 < context: component- scan base- package= " dao,domain,service" >
1316513120 < context: exclude- filter type= " annotation" expression= " org.springframework.stereotype.Controller" / >
0 commit comments