springboot 集成mybatis
(1) 添加启动器依赖;(自动添加 使用springboot init…勾选)
(2)配置Mybatis:实体类别名包,日志,映射文件等;
spring:
datasource:
password: 123456
username: root
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/springboot_test?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
mybatis:
type-aliases-package: com.csq.demo06mybatis.domain
mapper-locations: com.csq.demo06mybatis.dao
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl־
@SpringBootApplication
@MapperScan("com.csq.demo06mybatis.dao")//存放接口
public class Demo06mybatisApplication {
public static void main(String[] args) {
SpringApplication.run(Demo04mybatisApplication.class, args);
}
}