SpringBoot快速集成MyBatis

1.添加依赖

        
            org.mybatis.spring.boot
            mybatis-spring-boot-starter
            1.3.1
        
        
            mysql
            mysql-connector-java
            5.1.18
        
        
        
            c3p0
            c3p0
            0.9.1.2
        

2.在src/main/resources目录下创建mybatis-config.xml



    
    
        
        

        
        

        
        
    

3.在application.properties文件中添加如下配置

#配置数据源
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.url=jdbc:mysql://localhost:3306/mybatis?useUnicode=true&characterEncoding=utf8&useSSL=false&&serverTimezone=UTC
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#配置mybatis
mybatis.config-location=classpath:mybatis-config.xml
mybatis.mapper-locations=classpath:/mapper/**/*.xml
mybatis.type-aliases-package=com.demo.entity

你可能感兴趣的:(SpringBoot快速集成MyBatis)