欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

Spring中怎么整合MyBatis-創(chuàng)新互聯(lián)

本篇文章給大家分享的是有關(guān)Spring中怎么整合MyBatis,小編覺(jué)得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說(shuō),跟著小編一起來(lái)看看吧。

創(chuàng)新互聯(lián)是專業(yè)的蕭山網(wǎng)站建設(shè)公司,蕭山接單;提供網(wǎng)站設(shè)計(jì)、成都網(wǎng)站設(shè)計(jì),網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行蕭山網(wǎng)站開(kāi)發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛(ài)的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來(lái)合作!

1.導(dǎo)入所需要的jar依賴

!--MyBatis和Spring的整合包 由MyBatis提供-->
<dependency>
 <groupId>org.mybatis</groupId>
 <artifactId>mybatis-spring</artifactId>
 <version>1.3.0</version>
</dependency>
<!--MyBatis的核心jar文件-->
<dependency>
 <groupId>org.mybatis</groupId>
 <artifactId>mybatis</artifactId>
 <version>3.4.1</version>
</dependency>

2.MyBatis和Spring整合(XML版)

1.dao接口

Spring中怎么整合MyBatis

2.entity實(shí)體類

Spring中怎么整合MyBatis

3.service層接口

Spring中怎么整合MyBatis

4.serviceimpl實(shí)現(xiàn)類

Spring中怎么整合MyBatis

5.PersonDao.xml配置

Spring中怎么整合MyBatis

6.jdbc.properties配置

Spring中怎么整合MyBatis

7.大配置文件

<?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:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"

    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd

    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
  <!--<context:component-scan base-package="com.spring"/>-->
  <!-- 配置數(shù)據(jù)源 spring內(nèi)置的數(shù)據(jù)源-->
  <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${jdbc.driver}"></property>
    <property name="url" value="${jdbc.url}"></property>
    <property name="username" value="${jdbc.username}"></property>
    <property name="password" value="${jdbc.password}"></property>
  </bean>
  <!-- 引入屬性文件 -->
  <context:property-placeholder location="jdbc.properties.properties"/>
  <!--注冊(cè)DAO層:mapper的代理對(duì)象-->
  <bean id="personDao" class="org.mybatis.spring.mapper.MapperFactoryBean">
    <property name="mapperInterface" value="com.spring.dao.PersonDao"></property>
    <property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
  </bean>
  <!--配置service層對(duì)象-->
  <bean id="personService" class="com.spring.service.PersonServiceImpl">
    <property name="dao" ref="personDao"></property>
  </bean>
  <!-- sqlSessionFactory 創(chuàng)建SqlSession對(duì)象的工廠 -->
  <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource"></property>
    <!-- Mybatis的大配置文件 -->
    <property name="typeAliasesPackage" value="com.spring.entity"></property>
    <!-- 掃描sql配置文件:mapper需要的xml文件 -->
    <property name="mapperLocations" value="classpath*:mapper/*.xml"/>
  </bean>
  <!-- MapperScannerConfigurer 掃描mapper文件掃描器 -->
  <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="com.spring.dao"></property>
  </bean>

  <!-- transactionManager 事務(wù)管理器-->
  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"></property>
  </bean>
  <!-- 事務(wù)通知-->
  <tx:advice transaction-manager="transactionManager" id="txAdvice">
    <tx:attributes>
      <!--get系列方法設(shè)置事務(wù)的隔離級(jí)別和傳播行為-->
      <tx:method name="get*" isolation="READ_COMMITTED" propagation="REQUIRED"/>
    </tx:attributes>
  </tx:advice>
</beans>

8.測(cè)試類

Spring中怎么整合MyBatis

結(jié)果:

Spring中怎么整合MyBatis

以上就是Spring中怎么整合MyBatis,小編相信有部分知識(shí)點(diǎn)可能是我們?nèi)粘9ぷ鲿?huì)見(jiàn)到或用到的。希望你能通過(guò)這篇文章學(xué)到更多知識(shí)。更多詳情敬請(qǐng)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司行業(yè)資訊頻道。

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)建站aaarwkj.com,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

網(wǎng)頁(yè)題目:Spring中怎么整合MyBatis-創(chuàng)新互聯(lián)
文章來(lái)源:http://aaarwkj.com/article46/cdhihg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號(hào)、動(dòng)態(tài)網(wǎng)站域名注冊(cè)、服務(wù)器托管、搜索引擎優(yōu)化、面包屑導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)
亚洲欧美另类重口国产| 亚洲国产精品自拍第一页| 亚洲国产男同日韩小鲜肉| 十八岁毛片一区二区三区| 欧美一区二区三区va| 日本亚洲欧美男人的天堂| 国产男女猛烈无遮挡网站| 欧美日本国产老熟女视频| 久久产精品一区二区三区日韩 | 青青草原网址在线观看| 国产日产亚洲综合一区| 亚洲视频一区视频二区| 欧美在线观看日韩精品| 亚洲欧美日韩成人在线| 一区二区亚洲国产精品| 极品大胸美女被啪啪的高潮| 91国产网址在线观看| 亚洲综合一区二区精品久久| 欧美一区二区三在线| 国产乱国产乱老熟部视频| 欧美国产精品久久综合| 中文字幕乱码亚洲美女精品| 69久久精品费精品国产| 麻豆av永久地址久久精品| 亚洲精品中文字幕乱码| 九九re久久这里有精品| 欧美午夜精品福利在线观看| 蜜臀人妻久久一区二区三| 风韵丰满熟妇老熟女啪啪| 亚洲av男人的天堂看| 精品人妻人伦一区二区三区| 午夜在线观看视频免费| av在线日韩国产精品| 91女厕偷拍女厕偷拍| 色播婷婷午夜激情福利| 亚洲国产中日韩精品综合| av在线高清免费观看| 亚洲精品二区在线播放| av中文字幕一区二区三区| 免费高清av中文字幕| 年轻的少妇一区二区三区|