springboot 整合 mybatis

springboot 整合mybatis 简单配置

pom文件添加整合依赖和数据库连接依赖

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <scope>runtime</scope>
</dependency>
<!--集成mybatis依赖包-->
<dependency>
    <groupId>org.mybatis.spring.boot</groupId>
    <artifactId>mybatis-spring-boot-starter</artifactId>
    <version>1.3.1</version>
</dependency>

application.yml配置

 
 
spring:
  datasource:
    username: root
    password: root
    url:  jdbc:mysql://127.0.0.1:3306/springboottest
    driver-class-name:  com.mysql.jdbc.Driver
mybatis:
#实体类别名
  type-aliases-package: com.example.demo.entity
#  config-location:  classpath:mybatis/mybatis-config.xml
#mapper.xml 路径
  mapper-locations: classpath:mapper/*.xml
 
 

在启动类上添加@MapperScan扫描Dao接口



猜你喜欢

转载自blog.csdn.net/q845301261/article/details/80022079