Mybatis

输入参数类型 paramtertype:基本类型()      Java类型()待续。。。。。。。

输出参数类型 resultType: 待续。。。。。。。。

Mybatis&Spring整合

原生dao:

在ApplicationContext.xml中

<!-- 

    配置原生Dao实现 
    注意:class必须指定Dao实现类的全路径名称
-->
<bean id="xxxDao" class="com.fanfan.dao.XxxDaoImpl">
        <property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
</bean>

 Mapper代理

 在ApplicationContext.xml中

非包扫描😭

<bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"><!-- 配置mapper接口的全路径名称 -->
        <property name="mapperInterface" value="cn.itheima.mapper.UserMapper"></property>
<property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
</bean>

 包扫描方式✌

<!-- 使用包扫描的方式批量引入Mapper
     扫描后引用的时候可以使用类名,首字母小写.
-->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <!-- 指定要扫描的包的全路径名称,如果有多个包用英文状态下的逗号分隔 -->
        <property name="basePackage" value="cn.itheima.mapper"></property>
    </bean>

 

posted @ 2017-11-10 18:30  Atm_fan  阅读(156)  评论(0)    收藏  举报

12131313131