Mybatis的Mapper配置
来源:互联网 发布:手机怎么看淘宝保证金 编辑:程序博客网 时间:2024/06/05 00:13
1,在mybatis.xml中配置:
<mybatis:scan base-package="com.owen.mybatis.mappers" />
2,在application.xml中配置(Spring):
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="mapperLocations" value="classpath*:mapping/*.xml" />
</bean>
3,在SpringBoot中的两种配置:
a.@MapperScan(value="com.mzqx.springboot.mapper")
b.@Configuration
@AutoConfigureAfter(MybatisConfig.class) //保证在MyBatisConfig实例化之后再实例化该类
public class MapperScannerConfig {
// mapper接口的扫描器
@Bean
public MapperScannerConfigurer mapperScannerConfigurer() {
MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
mapperScannerConfigurer.setBasePackage("com.mzqx.springboot.mapper");
return mapperScannerConfigurer;
}
<mybatis:scan base-package="com.owen.mybatis.mappers" />
2,在application.xml中配置(Spring):
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="mapperLocations" value="classpath*:mapping/*.xml" />
</bean>
3,在SpringBoot中的两种配置:
a.@MapperScan(value="com.mzqx.springboot.mapper")
b.@Configuration
@AutoConfigureAfter(MybatisConfig.class) //保证在MyBatisConfig实例化之后再实例化该类
public class MapperScannerConfig {
// mapper接口的扫描器
@Bean
public MapperScannerConfigurer mapperScannerConfigurer() {
MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
mapperScannerConfigurer.setBasePackage("com.mzqx.springboot.mapper");
return mapperScannerConfigurer;
}
}
阅读全文
0 0
- mybatis mapper的配置
- Mybatis的Mapper配置
- Mybatis的配置Mapper方法
- mybatis之mapper的配置
- mybatis的mapper配置方式
- Mybatis中配置Mapper的方法
- Mybatis中配置Mapper的方法
- Mybatis中配置Mapper的方法
- Mybatis中配置Mapper的方法
- Mybatis中配置Mapper的方法
- Mybatis中配置Mapper的方法
- Mybatis中配置Mapper的方法
- Mybatis中配置Mapper的方法
- Mybatis中配置Mapper的方法
- Mybatis中配置Mapper的方法
- Mybatis中配置Mapper的方法
- mybatis的Mapper XML文件配置
- Mybatis中配置Mapper的方法
- Oracle 数据泵导入导出总结
- python爬虫基础知识(一)--Urllib.request
- 实训第一天之bootsrtap、html、js的使用
- 完美解决android Studio打开报错 https://code.google.com/p/android/issues
- Hyperledger Fabric 1.0 实战开发系列 第二课 Fabric环境搭建
- Mybatis的Mapper配置
- 航信校招java笔试题
- ROS在树莓派上的安装
- JavaScript学习(一)
- 远程访问Linux服务器(CentOs 6.9)
- XRecyclerView框架中所遇到的bug,.XRecyclerView$DataObserver@3f43b8 is already registered
- 今天的主题是时间管理
- 原生JS解决getElementsByClassName浏览器兼容问题(适用于多个类名)
- C语言简单编程之一元二次方程求解