java 谷粒商城报错 2023/7
自己做的时候遇到的问题总结
1.后端报德鲁伊配置过时,配置源加个cj,改成
driver-class-name: com.mysql.cj.jdbc.Driver
2.报错:The server time zone value ‘�й���ʱ��‘ is unrecognied
解决方法1
将JDBC连接的URL修改为:jdbc:mysql://localhost:3306/数据库名?serverTimezone=UTC
这里UTC代表全球标准时间,可以根据需要更改其值。
我们使用的时间是北京时间,即东八区时间,领先UTC八个小时。
所以我们可以将URL修改为:jdbc:mysql://127.0.0.1:3306/test?serverTimezone=GMT%2b8
//上海时区也为东八区
jdbc:mysql://localhost:3306/数据库名?serverTimezone=Asia/Shanghai
解决方法2
当然我们可以直接通过更改使用的驱动包版本来解决该问题,只要使用6以下的版本就能解决。
3.【谷粒商城】3、找不到 longblob
报红的 longblob 改成 byte[]
4.nacos中startup.cmd启动不行和idea中报错

或者另一种方法用文件编辑器打开startup.cmd,修改成以下样子

idea启动注册中心报错“com.google.common.collect.Sets$SetView.iterator()Lcom/google/co”,引入以下依赖
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.1-jre</version>
</dependency>
5.spring.cloud,nacos.config,ext-config弃用
改为spring.cloud.nacos.config.extension-configs[0].data-id=datasource.yaml
6.gateway引入启动报错Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway. Action: Please set spring.main.web-application-type=reactive or remove spring-boot-starter-web dependency.
在application.properties中额外添加这一行spring.main.web-application-type=reactive
7.Property: spring.cloud.gateway.routes[0].uri Value: "null" Reason: 不能为null Action: Up
断言地址 url--->uri
8.前端验证码出不来,标记部分改成如下(说的是springboot2.4之后都用allowedoriginpatterns不用allowedorigin)
@Configuration
public class CorsConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOriginPatterns("*")
.allowCredentials(true)
.allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
.maxAge(3600);
}
}
9.An attempt was made to call a method that does not exit
最后面有一句是文件位置:删掉这个jar文件即可

10.p63的nacos注册不上third-party
将nacos配置的内容复制粘贴给本地的yml
11.单元测试异常:InvalidTestClassError: Invalid test class : 1. Method testConnect () should be public
• 你使用了org.junit.jupiter.api.Test,这是JUnit5的注解,但你又使用了@RunWith(SpringRunner.class),这是JUnit4的注解。你应该使用org.springframework.test.context.junit.jupiter.SpringExtension来替代SpringRunner,并且使用@ExtendWith(SpringExtension.class)来替代@RunWith(SpringRunner.class)。
12.Invalid prop: type check failed for prop "filterable". Expected Boolean, got String.
filterable默认为false,如果我们设置此filterable属性的话,不用写“filterable:true”,只需要写上“filterable”就代表它被设置为true了。

浙公网安备 33010602011771号