Spring Learning (vii) Spring integration MyBatis

Source: Internet
Author: User

Compared to the usual wording of MyBatis, Spring uses mybatis without mybatis-config.xml configuration and Mybatisfactory factory, which can be configured in Applicationcontext.xml.
Or use the last case: MyBatis Portal
Attached applicationcontext.xml:

<beans xmlns="Http://www.springframework.org/schema/beans"xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="Http://www.springframework.org/schema/beans http://www.springframework.org/ Schema/beans/spring-beans-3.2.xsd ">            <!--configuring Sqlsessionfactory in an IOC container using Sqlsessionfactorybean factory Bean 1 Configuration Data source 2 configuration Map File Note CLASSPATH prefixes each add a mapping file to the project, you need to add a value element to the list--     <bean id="SSF" class="Org.mybatis.spring.SqlSessionFactoryBean" >        < property name="DataSource" ref="ds"></Property >        < property name="Mapperlocations">            <list>                <value>Classpath:com/etoak/dao/citydaoif-mapper.xml</value>            </list>        </Property >     </Bean>     <bean id= "ds" class=" Org.springframework.jdbc.datasource.DriverManagerDataSource ">        < property name= "driverclassname" value=" Com.mysql.jdbc.Driver "></Property >        < property name="url" value="Jdbc:mysql://localhost:3306/yitu" ></Property >        < property name="username" value="root"></Property >        < property name="password" value="root"></Property >     </Bean>     < Instance bean object corresponding to the!--configuration interface spring in order to configure the interface instance, provide Mapperfactorybean factory bean--      <bean id="DAO" class=" Org.mybatis.spring.mapper.MapperFactoryBean ">        < property name="Sqlsessionfactory" ref="SSF"></Property >        < property name= "mapperinterface" value=" Com.etoak.dao.CityDaoIf "></Property >              </Bean>      <!--each add an interface to the project, you need to add a separate bean node to the IOC container using the Mapperinterface instantiation interface--</Beans>

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Spring Learning (vii) Spring integration MyBatis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.