项目启动时报错:

java.lang.RuntimeException: java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowedat com.baomidou.mybatisplus.generator.config.DataSourceConfig.getConn(DataSourceConfig.java:207)at com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder.handlerDataSource(ConfigBuilder.java:277)at com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder.<init>(ConfigBuilder.java:140)at com.baomidou.mybatisplus.generator.AutoGenerator.execute(AutoGenerator.java:93)at com.veryreader.d2p.generator.services.GenerateServiceImpl.generate(GenerateServiceImpl.java:154)at com.veryreader.d2p.generator.CodeGeneratorApplicationTests.pm(CodeGeneratorApplicationTests.java:30)……

解决方法

解决办法:
1.使用Navicat连接数据库,重启测试
若仍不能解决,则:

2.在项目配置文件数据库url后拼接(允许从服务器获取公钥):

&allowPublicKeyRetrieval=true

此项默认为false,需显示启用

全部url:

url: jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true

重新启动,问题解决