IDEA配置
IDEA安装MyBatisX插件。
根据IDEA指引来创建Spring Boot项目mybatisplus-demo1。
添加依赖
添加mybatisplus和lombok依赖
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
添加文件
application.yml
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: root
url: jdbc:mysql://xx.xx.xx.xx:3306/test?useUnicode=true&characterEncoding=utf8
# 输出sql信息
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
问题1:userMapper飘红
搜索Autowiring for Bean Class
问题2:Cannot load driver class: com.mysql.cj.jdbc.Driver
添加mysql依赖后reimport
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
问题3:No qualifying bean of type 'com.wjq.mapper.UserMapper' available
@SpringBootApplication上面添加@MapperScan("com.wjq.mapper")。
标签:jdbc,使用,IDEA,xx,添加,Plus,mysql,MyBatis,com From: https://www.cnblogs.com/WJQ2017/p/17556234.html