当前位置: 首页 > wzjs >正文

个人备案后做淘客网站百度seo是什么

个人备案后做淘客网站,百度seo是什么,如何做收费视频互动网站,网站制作哪里好薇1.spring-mybatis整合 因此我们下面主要就是讲解,spring-mybatis怎么整合?(那么为什么需要整合,最主要就是事务这方面,因为在mybatis里面我们进行操作的时候都需要进行操作,我们根据spring的特性AOP&#x…

1.spring-mybatis整合

因此我们下面主要就是讲解,spring-mybatis怎么整合?(那么为什么需要整合,最主要就是事务这方面,因为在mybatis里面我们进行操作的时候都需要进行操作,我们根据spring的特性AOP,我们可以横向切面将其进行插入!!!)

要了解整合我们就需要回顾一下我们的mybatis是什么结构,有了结构之后我们才能知道是怎么进行整合的!!!

mybatis框架:

Spring-mybatis整合框架:

整合上图中的2:

spring对于new出的东西可以进行bean容器存储的,因此我们可以对mybatisConfig.xml这个文件处理,然后我希望就是mybatis原有的别名以及设置我是不希望进行变化的!!!

还有就是简化关系dataSource进行简化

以及绑定

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:c="http://www.springframework.org/schema/c"xmlns:p="http://www.springframework.org/schema/p"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsd"><!--DataSource,使用spring的数据源替换mybatis配置--><bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"><property name="driverClassName" value="com.mysql.jdbc.Driver"/><property name="url" value="jdbc:mysql://localhost:3306/account?useUnicode=true&amp;characterEncoding=utf-8&amp;allowMultiQueries=true&amp;useSSL=false&amp;serverTimezone=GMT%2b8&amp;allowPublicKeyRetrieval=true
"/><property name="username" value="root"/><property name="password" value="123456"/></bean><!--  sqlSessionFactory创建配置省略--><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="dataSource"/>
<!-- 绑定原有mybatis的配置文件
其实可以全部省略,但是我们还是希望在原有的mybatis里面进行一些别名,设置等配置
--><property name="configLocation" value="classpath:Mybatis-config.xml"/><property name="mapperLocations" value="classpath:com/xcl/dao/*.xml"/></bean><!-- sqlSessionTemplate配置,其实就是我们的sqlSession一样只是在spring里面换了一个名字!--><bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate"><constructor-arg index="0" ref="sqlSessionFactory"/></bean></beans>

因为我们需要使用注入bean,因此我们是需要创建一个实体类,去实现接口,然后注入我们sqlSessionTemplate,然后再xml里面进行什么声明!

package com.xcl.dao;import com.xcl.pojo.User;
import org.mybatis.spring.SqlSessionTemplate;import java.util.List;public class UserMapperImp implements UserMapper{//我们所有操作。都是使用sqlSession来执行,现在都是使用SqlSessionTemplateprivate SqlSessionTemplate sqlSessionTemplate;//set方法,注入sqlsessionTemplatepublic void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {this.sqlSessionTemplate = sqlSessionTemplate;}@Overridepublic List<User> findAll() {UserMapper mapper = sqlSessionTemplate.getMapper(UserMapper.class);return mapper.findAll();}
}

自此我们spring-mybatis整合已经弄完了!

2.使用spring中的AOP对事务进行处理

下面我们举个例子:

我故意把delete写成deletee,使得我们插入了但是并没有对其进行删除,但是结果是报错了但是我们也同样进行插入!

因此我们需要对这些操作进行事务的管理,其实就是加一下配置就行!!!


<!--结合AOP实现事务的织入-->
<!-- 配置事务的通知--><tx:advice id="txAdvice" transaction-manager="transactionManager">
<!-- 配置事务属性--><tx:attributes><tx:method name="addUser" propagation="REQUIRED"/><tx:method name="deleteUser" propagation="REQUIRED"/><tx:method name="updateUser" propagation="REQUIRED"/><tx:method name="find" propagation="SUPPORTS" read-only="true"/><tx:method name="*" propagation="REQUIRED"/></tx:attributes></tx:advice><!-- 事务的切入点--><aop:config><aop:pointcut id="txPointcut" expression="execution(* com.xcl.dao.UserMapper.*(..))"/><aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/></aop:config>

http://www.dtcms.com/wzjs/315995.html

相关文章:

  • 北京cbd网站建设公司seo外包公司多少钱
  • 免费开网店汉中网站seo
  • 个人做网站接装修活哪个网站好seo网站优化公司
  • 网站托管目的是什么深圳百度seo怎么做
  • 东莞东城网站建设软文写作模板
  • 如何自己做网站可以百度到重庆seo教程
  • 云南建设项目招标公告发布网站搜索引擎入口网址
  • 百度收录网站多久福州seo优化排名推广
  • wordpress搜索过滤长沙排名优化公司
  • ui作品集展示模板刷网站seo排名软件
  • 网站建设具体步骤西安专业做网站公司
  • 做网站logo的网站大连最好的做网站的公司
  • 周至县做网站郑州seo服务技术
  • 广西网络公司有几家网站搜索优化找哪家
  • wordpress备份网站网上怎么推广产品
  • 网站防恶意注册seo推广薪资
  • 做招投标有哪些网站搜索网站大全
  • 织梦做单页面网站网上销售有哪些方法
  • 免费响应式网站模板软文范例大全1000字
  • 系统学做网站seo属于什么职位类型
  • 潍坊专业网站建设多少钱seo关键词排名优化品牌
  • 哪些做直播卖食品的网站app怎么开发出来的
  • 南昌做网站的公司哪家好买卖交易网
  • 神华科技 网站建设蚌埠seo外包
  • 老君山旅游网页设计模板汕头seo外包公司
  • dreamweaver网页设计配伍题网站的seo
  • 南昌网站优化百度seo优化及推广
  • 如何用java做网站界面合肥品牌seo
  • 服务专业公司网站建设服务佛山网站营销推广
  • 如何在网站做404页面chatgpt网站