运行
java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
初步判断是驱动的问题,在pom.xml上设置版本号(很多都是5.7版本,现在大多是8.0版本)
<!--Mysql--> <dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-j</artifactId> <scope>runtime</scope> <version>8.0.31</version> </dependency>
再次启动依然报错,于是仔细查看后发现是application.yml的URL配置有误,
create connection SQLException, url: jdbc:mysql://localhost:3306/enterprise_digital?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai, errorCode 0, state 08001
之前用的数据库是网络公共的,后来用的自己的数据库更改了相关配置,多加了东西,改正过来即可正常使用
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/enterprise_digital?serverTimezone=UTC&serverTimezone=Asia/Shanghai
username: root
password: 123321