SpringBoot整合MybatisPlus报错Failed to load driver class com.mysql.cj.jdbc.Driver

SpringBoot项目连接数据库报错整合MyBatis 报错
1、Failed to load driver class com.mysql.cj.jdbc.Driver
2、Field cityClient in com.example.controller.HttpController required a bean of type ‘com.example.demo.****’ that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)

===============================================
我竟然发现是自己连接数据库的依赖忘记加了(粗心大意的自己)

 <dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.48</version>
		</dependency>

而且整的自己对于SpringBoot连接数据库的配置也不确定了(记录一下application.yml)

spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/test1?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false
    username: root
    password: 123456

在加一个MybatisPlus的配置

mybatis-plus:
  type-aliases-package: com.example.demo.sys.entity 
  mapper-locations: classpath:/mapper/**.xml

你可能感兴趣的:(java,MybatisPlus,SpringBoot)