mybatis配置文件

来源:互联网 发布:咸鱼如何申请淘宝介入 编辑:程序博客网 时间:2024/06/07 01:27

1.mybatis核心配置文件

配置别名,mapper.xml文件的位置,插件
例如开启驼峰自动转换,配合别名简化mapper文件的书写

    <settings>        <setting name="mapUnderscoreToCamelCase"  value="true"/>    </settings>

2.mybatis和spring的整合配置文件

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">        <!-- 配置数据源 -->        <property name="dataSource" ref="dataSource" />        <!-- 配置mybatis核心配置文件 -->        <!-- sqlMapConfig是mybatis默认的名字,但语意性不够强,可以改名字比如mybatis-config -->        <property name="configLocation" value="classpath:mybatis/mybatis-config.xml"/>        <!-- 配置mapper.xml文件的位置 -->        <property name="mapperLocations" value="classpath*:mybatis/**/*Mapper.xml"/>        <!-- 设置别名 -->        <property name="typeAliasesPackage" value="com.mybatis.test.*.model"/>    </bean>    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">        <property name="basePackage" value="com.mybatis.test.*.dao" />    </bean>
原创粉丝点击