博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SpringBoot学习:整合Mybatis,使用HikariCP超高性能数据源
阅读量:6737 次
发布时间:2019-06-25

本文共 1169 字,大约阅读时间需要 3 分钟。

一、添加pom依赖jar包:

1  
2
3
org.mybatis.spring.boot
4
mybatis-spring-boot-starter
5
1.1.1
6
7 8
9
10
com.zaxxer
11
HikariCP-java6
12
2.3.9
13
compile
14

 

二、项目结构:

  Mapper文件在resources目录下。并在SpringBoot入口类中添加 @MapperScan("cn.com.venus.oa.mapper") @ServletComponentScan 注解

  

 在入口类上添加注解,配置Mapper接口的地址

1 @ServletComponentScan2 @MapperScan("cn.com.venus.oa.mapper")3 public class venusAppcliation {4   ...  5 }

 

     @ServletComponentScan: 设置启动时spring能够扫描到我们自己编写的servlet和filter

  @MapperScan: 用于扫描的mapper接口

在yml配置文件中:

1 spring: 2   datasource: 3     driver-class-name: com.mysql.jdbc.Driver 4     url: jdbc:mysql:///venus 5     username: root 6     password: admin 7  8   mvc: 9     view:10       prefix: /WEB-INF/pages/11       suffix: .jsp12       13  mybatis:14   type-aliases-package: cn.com.venus.oa.pojo15   config-location: classpath:/mybatis/mybatis-config.xml16   mapper-locations: classpath:/mybatis/mappers/*.xml

 

转载于:https://www.cnblogs.com/tongxuping/p/7207695.html

你可能感兴趣的文章
H3C防火墙的dns-map功能
查看>>
iOS 9 点击右上角退回到上一App时 屏幕会闪一下
查看>>
我的友情链接
查看>>
数组与指针(一)
查看>>
I/O模型分类
查看>>
智能照明控制系统
查看>>
Shiro的Demo示例
查看>>
RISC领域ARM不是唯一
查看>>
数据库容灾的最高境界
查看>>
spark命令
查看>>
mysql explain中的select tables optimized away---(二)
查看>>
安装PHP5和PHP7
查看>>
邹承鲁院士谈学术文献阅读
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
android模仿铃声选择功能
查看>>
我的友情链接
查看>>
配置DHCP服务器
查看>>
trim triml trimr
查看>>