报错:
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
原因:MySQL服务关闭
解决办法:打开MySQL服务,右键点击开始:
报错:
xxxMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
原因:
检查启动类是否添加了@ScanMapper(com.xxx.xxx.mapper)同时检查mapper路径是否正确
解决方法:
启动类增加ScanMapper注解及mapper位置
报错:
Error creating bean with name ‘gatewayConfigurationService‘ defined in class path resource
因为gateway和zuul不一样,gateway用的是长连接,netty-webflux,zuul1.0用的就是同步webmvc。所以你的非gateway子项目启动用的是webmvc,你的gateway启动用的是webflux. spring-boot-start-web和spring-boot-start-webflux相见分外眼红。不能配置在同一pom.xml,或者不能在同一项目中出现
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
和
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId>
</dependency>
不能在同一个 pom文件下,用gateway就不要有 boot-starter-web这个依赖
报错:
"nacos is starting with standalone"
Error occurred during initialization of VM
Could not reserve enough space for object heap
如果直接点击nacos文件夹下bin目录下的 startup.cmd 会报错,这是由于nacos默认会以集群模式启动,如果想单机测试启动的话,需要:
1.进入 nacos 的 bin 文件夹下,输入 cmd ,即可进入bin目录下得cmd窗口;
2.输入 startup.cmd -m standalone 回车,即可启动成功。
报错:
在nacos上配置后发现报错,且服务列表中没有对应的服务
nacos: java,lang.IllegalArgumentException:no server
检查bootstarp.yml文件查看是否配置了服务注册和发现,正确如下所示:
spring:application:name: xxx # 微服务名profiles:active: devcloud:nacos:config:server-addr: localhost:8848 # nacos 服务端地址file-extension: ymldiscovery: # 服务发现server-addr: localhost:8848 # nacos 服务端地址cluster-name: HZ # 配置集群名称,也就是机房位置,例如:HZ,杭州 可不写
报错:
SqlSession was not registered for synchronization because synchronization is not active
解决方法:
serviceImpl增加注解@@Transactional
多数据配置时报错:
dynamic-datasource can not find primary datasource
检查yml配置格式:
正确如下:
# 正确格式
spring:datasource:dynamic:strict: falseprimary: onedatasource:one:driver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://localhost:3306/demo?allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=falseusername: rootpassword: 123456two:driver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://localhost:3306/demo1?allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=falseusername: rootpassword: 123456
报错:
Content type ‘multipart/form-data;boundary=xxxx
解决方法:删掉@RequestBody或者测试POST的时候使用json
报错:
Column count doesn‘t match value count at row 1
解决方法:
检查mybatis的insert 列
上下不对应不匹配。
示例是 insert into user(colum1,colum2,colum3)
但是values是(字段1,字段2)这种信息。列名不匹配
invalid bound statement(not found)
查看mapper文件中的namespace是否正确对应