Spring Boots &mybatis连接数据库配置步骤
来源:互联网 发布:linux下c 多线程 编辑:程序博客网 时间:2024/06/06 01:35
1. 5个包 放到 POM
<!--mybatis --><dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId></dependency><dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.1.1</version></dependency><!--commons --><dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.6</version></dependency><dependency> <groupId>commons-configuration</groupId> <artifactId>commons-configuration</artifactId> <version>1.10</version></dependency><dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.5</version></dependency>
2. 生产项目MAVEN 依赖
3. config aplication.java
//增加持久层
@MapperScan("com.jm.dao")
4. config application.yml
datasource:
url: jdbc:oracle:thin:@20.1.10.18:1521:jiumao
username: jiumao
password: 123456
mybatis:
configuration:
map-underscore-to-camel-case: true
5.dao
import com.jm.Model.UserDB;
import org.apache.ibatis.annotations.Select;
//注意这里是interface
public interface UserMapper {
//@Select("select `username`, `password` from user where username = #{username}")
// User getByUsername(String username);
//z这里没有分号
@Select("select 'userid' , 'username' , 'userno' ,'password'from users where username=#{username}")
UserDB getByUsername(String username);
}
6. @Autowired controller
@Autowired
UserMapper userMapper;
阅读全文
0 0
- Spring Boots &mybatis连接数据库配置步骤
- spring boots 配置neo4j 主要步骤
- Spring Boot MyBatis 连接数据库
- spring boot mybatis连接数据库
- Spring Boot MyBatis 连接数据库
- Spring Boot MyBatis 连接数据库
- Spring Boot MyBatis 连接数据库
- Spring Boot MyBatis 连接数据库
- jdbc、hibernate、mybatis连接数据库步骤
- spring配置连接数据库
- mybatis + spring 的基本配置步骤
- SSM(spring+springMVC+Mybatis)配置步骤
- Spring+Mybatis配置主从数据库
- 使用Mybatis+Spring,连接多个数据库
- spring mybatis不能使用变量连接数据库
- Spring boot 用mybatis连接数据库
- spring boot 通过mybatis连接MySQL数据库
- 使用Mybatis+Spring,连接多个数据库
- leetcode 141. Linked List Cycle 链表循环的判定 + 双指针
- 使用Halcon实现图像处理
- openwrt menuconfig恢复默认配置
- java三种方式实现键盘录入
- SpringMVC通过Controller实现页面跳转
- Spring Boots &mybatis连接数据库配置步骤
- docker中使用gitlab笔记
- 以SpringIoc的模拟实现来学习反射和xml解析
- 解决端口(8080)被占用情况
- Tensorflow-DNN
- Java垃圾收集器
- 第十九篇 jQuery初步学习
- 第十一天:图像阈值化简介
- 堆外内存之 DirectByteBuffer 详解