连接MySQL

引入依赖

  1. <!-- mysql 5 -->
  2. <!-- <dependency>-->
  3. <!-- <groupId>mysql</groupId>-->
  4. <!-- <artifactId>mysql-connector-java</artifactId>-->
  5. <!-- <version>5.1.27</version>-->
  6. <!-- </dependency>-->
  7. <!-- mysql 8 -->
  8. <dependency>
  9. <groupId>mysql</groupId>
  10. <artifactId>mysql-connector-java</artifactId>
  11. <version>8.0.15</version>
  12. </dependency>

Yaml配置

  1. # 数据库连接信息
  2. spring:
  3. datasource:
  4. #MySQL 5
  5. #driver-class-name: com.mysql.jdbc.Driver
  6. #MySQL 8
  7. driver-class-name: com.mysql.cj.jdbc.Driver
  8. url: jdbc:mysql://192.168.1.125:3306/ithink-cms?serverTimezone=UTC&useSSL=false
  9. username: root
  10. password: aaaaaa

常见问题