zoukankan      html  css  js  c++  java
  • MyBatis SpringMVC映射配置注意

    applicationContext.xml中要配置

    <!-- MyBatis 的 sqlSessionFactory -->
        <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        	<property name="dataSource" ref="dataSource"/>
        	  <property name="configLocation">
                <value>classpath:sqlMapConfig.xml</value>
            </property>
        </bean>
        
    
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        	<property name="basePackage" value="cn.baseapp.dao"/>
        	<!-- 
        	<property name="sqlSessionTemplateBeanName" value="sqlSessionTemplate" />
    		<property name="annotationClass" value="org.springframework.stereotype.Repository" />
    		 -->
        </bean>
    

     MapperScannerConfigurer 支 持 过 滤 由 指 定 的 创 建 接 口 或 注 解 创 建 映 射 器 。 annotationClass 属性指定了要寻找的注解名称。 markerInterface 属性指定了要寻找的父 接口。如果两者都被指定了,加入到接口中的映射器会匹配两种标准。 默认情况下,这两个 属性都是 null,所以在基包中给定的所有接口可以作为映射器加载。因此 annotationClass 写不写都行,只要包指定到dao上就行了

    参考 https://my.oschina.net/psuyun/blog/464851

    用通配符配置 mapper

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
      <property name="dataSource" ref="dataSource" />
      <property name="configLocation" value="classpath:sqlMapConfig.xml"/>
      <property name="mapperLocations" value="classpath*:sample/config/mappers/**/*.xml" />
    </bean>
  • 相关阅读:
    在am中定义消息集束,并在CO中验证之后抛出异常。
    在EORow或者VORow中对数据进行重复性校验
    axis2 webservice jar包使用情况(转)
    std::function以及std::bind
    Qt学习过程
    NULL和nullptr
    清空表且id为0
    C++线程互斥、同步
    warning: deleting 'void *' is undefined 错误
    Classification / Recognition
  • 原文地址:https://www.cnblogs.com/coolzdp/p/7134443.html
Copyright © 2011-2022 走看看