springboot项目使用注解法整合mybatis的具体步骤
来源:互联网 发布:三国战记tas软件 编辑:程序博客网 时间:2024/05/25 08:14
1.properties文件添加如下配置
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:orcl
spring.datasource.username=boot_user
spring.datasource.password=boot_user
mybatis.config-location=classpath:configs/mybatis-config.xml
mybatis.mapper-locations=classpath:com/study/bootstudy/mapper/*.xml
mybatis.type-aliases-package=com.study.bootstudy.model
2.pom.xml文件添加如下配置
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>11.1.0.6.0</version>
</dependency>
注意:maven仓库不支持,ojdbc14未授权,需下载后,使用cmd手动导入本地仓库
3.application.java类添加以下注解,扫描DAO层(mapper接口)接口类,并注入上下文
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:orcl
spring.datasource.username=boot_user
spring.datasource.password=boot_user
mybatis.config-location=classpath:configs/mybatis-config.xml
mybatis.mapper-locations=classpath:com/study/bootstudy/mapper/*.xml
mybatis.type-aliases-package=com.study.bootstudy.model
2.pom.xml文件添加如下配置
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>11.1.0.6.0</version>
</dependency>
注意:maven仓库不支持,ojdbc14未授权,需下载后,使用cmd手动导入本地仓库
3.application.java类添加以下注解,扫描DAO层(mapper接口)接口类,并注入上下文
@MapperScan("com.study.bootstudy.dao")
与properties文件中的*mapper.xml文件sql相匹配,实现sql和java代码分离
阅读全文
0 0
- springboot项目使用注解法整合mybatis的具体步骤
- springboot整合mybatis 注解实现
- 一个简单的SpringBoot整合Mybatis项目
- SpringBoot整合Mybatis的简单例子(注解版)
- Springboot整合mybatis项目开发
- springboot之整合mybatis-annotation(注解方式)
- 5.springboot整合mybatis(注解方式)
- springboot 注解方式整合mybatis (mysql数据库)
- springboot与mybatis的整合
- springboot与mybatis的整合
- 全注解方式整合spring+mybatis模拟springboot整合
- SpringBoot+Mybatis项目使用Redis做Mybatis的二级缓存
- 关于springboot整合mybatis,做关联查询的两种方式(注解和配置文件)
- springboot中使用Mybatis注解配置详解
- springboot 整合mybatis 基于注解开发 传入对象
- Java SpringMVC MyBatis整合项目 注解
- Springboot 整合 Mybatis 的完整 Web 案例
- Springboot 整合 Mybatis 的完整 Web 案例
- android ANR源码分析 --- 之二
- ui-router 使用resolve进行数据预加载
- Oc Plist 持久化
- 入门Webpack,看这篇就够了
- Python defaultdict用法
- springboot项目使用注解法整合mybatis的具体步骤
- Oc 数据库SQLite3
- 算法模板——树链剖分
- 进程间通信——管道
- 二进制转十六进制 算法实现思想
- 20171031 web开发中的session
- 计算几何
- 使用VS2017开发ActiveX控件来显示视频
- Oc 数据持久化Plist、SQLite、CoreData、FMDB四种-demo