目录

SpringBoo集成MyBaits的步骤如下:

1.在pom.xml中配置相关jar依赖

2.在Springboot的核心配置文件application.properties中配置MyBaits的Mapper.xml文件所在位置:

3.在springboot的核心配置文件application.properties中配置数据源:

4.在Myaits的Mapper接口中添加@Mapper注解或者在运行的主类上添加@MapperScan(com.luluyu.springboot.mapper)注解包扫描


1.在pom.xml中配置相关jar依赖

<!-- 加载mybatis整合springboot -->

<dependency>

<groupId>org.mybatis.spring.boot</groupId>

<artifactId>mybatis-spring-boot-starter</artifactId>

<version>1.3.1</version>

</dependency>

 

<!-- MySQL的jdbc驱动包 -->

<dependency>

<groupId>mysql</groupId>

<artifactId>mysql-connector-java</artifactId>

</dependency>

2.在Springboot的核心配置文件application.properties中配置MyBaits的Mapper.xml文件所在位置:

mybaits.mapper-location=class:com/luluyu/springboot/mapper/*.xml

springboot学习总结五(Spring boot集成MyBaits)

3.在springboot的核心配置文件application.properties中配置数据源:

#配置数据库连接信息

spring.datasource.username=root

spring.datasource.password=root

spring.datasource.driver-class-name=com.mysql.jdbc.Driver

spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=false

4.在Myaits的Mapper接口中添加@Mapper注解或者在运行的主类上添加@MapperScan(com.luluyu.springboot.mapper)注解包扫描

springboot学习总结五(Spring boot集成MyBaits)

相关文章:

  • 2021-09-20
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2022-01-14
  • 2021-04-17
  • 2022-01-02
  • 2021-10-22
猜你喜欢
  • 2021-09-17
  • 2021-04-08
  • 2022-12-23
  • 2021-11-26
  • 2021-09-09
  • 2021-12-28
  • 2021-10-10
相关资源
相似解决方案