文章目录
- 跨域问题
- Invalid prop: type check failed for prop “min“. Expected Number, got String
- Uncaught (in promise) cancel
- 在 created 的方法中清空表单失效
- Failed to configure a DataSource
- 403
- 添加课程重置表单时二级联动和课程封面失效
- 重置表单时富文本没有重置
- org.apache.ibatis.binding.BindingException
- Exception in thread "main" com.aliyuncs.exceptions.ClientException: Forbidden.AliyunVoDEncryption
- FileSizeLimitExceededException
- 413 (Request Entity Too Large)
- no server available
- nuxt依赖下载失败,npm WARN Invalid name: “{ { name }}“
- Error: Could not compile template
- npm install 下载太慢
- P144-14_技术点-阿里云视频点播(依赖引入)
- Required request body is missing
- Caused by: java.sql.SQLException: #HY000
- java.lang.IllegalArgumentException: no server available
- Caused by: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: #22001
- P197 Unexpected token o in JSON at position 1
- P201 redirect_uri 参数错误
- P210可重复发送请求的 以及前一页后一页的bug
- org.springframework.beans.factory.UnsatisfiedDependencyException
- Data source rejected establishment of connection, message from server: ""
- feign.FeignException$NotFound: status 404 reading
- Cause:java.sql.SQLException: Unknown error 1045
跨域问题
Access to XMLHttpRequest at ‘http://localhost:9001/eduservice/user/login’ from origin ‘http://localhost:9528’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
原因:
通过一个地址去访问另外一个地址,这个过程中如果有三个地方任何一个不一样
访问协议 http https
ip地址 192.168.1.1 202.168.11.11
端口号 8080 9528
解决办法:
(1)在后端接口Controller 添加注解 @CrossOrigin
(常用)
@CrossOrigin //解决跨域
public class EduLoginController {
}
(2)使用网关解决
Invalid prop: type check failed for prop “min“. Expected Number, got String
将 min
改成 :min
带冒号
错误原因:min max 之类,使用组件的话应为 :min :max
Uncaught (in promise) cancel
原因:
this.$confirm方法内置promise方法,
所以不能把.catch()去掉(因为取消操作时,无法捕获)
解决办法:
在this.$confirm方法后加上.catch
方法即可,注意要写上空方法体
.catch(()=>{
});
在 created 的方法中清空表单失效
多次路由跳转到同一个页面,在页面中
created
方法只会执行第一次,后面在进行跳转不会执行的
解决办法: 使用 侦听器
//监听
watch: {
//路由变化方式,路由发生变化,方法就会执行
$route(to, from) {
console.log("watch $route");
this.init();
},
},
//页面渲染之前执行
created() {
this.init();
},
methods: {
init() {
//判断路径是否有id值
if (this.$route.params && this.$route.params.id) {
//从路径获取id值
const id = this.$route.params.id;
//调用根据id查询的方法
this.getInfo(id);
//没有id 做添加
} else {
this.teacher = {
};
}
},
}
Failed to configure a DataSource
Description:
Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
spring boot 会默认加载org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration这个类,
而DataSourceAutoConfiguration类使用了@Configuration注解向spring注入了dataSource bean,又因为项目(oss模块)中并没有关于dataSource相关的配置信息,所以当spring创建dataSource bean时因缺少相关的信息就会报错。
解决办法:
方法1、在@SpringBootApplication注解上加上exclude,解除自动加载DataSourceAutoConfiguration
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
403
CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
原因:
- 跨域
- 路径资源不存在(路径写错了)
添加课程重置表单时二级联动和课程封面失效
解决办法:
不能直接令 this.courseInfo = {}
这样会清空属性和值, 也就是说要保留属性令值为空即可
而应使用默认值
this.courseInfo = {
title: "",
subjectId: "",
subjectParentId: "", //一级分类
teacherId: "",
lessonNum: 0,
description: "",
cover: "/static/weixinpay.jpg",
price: 0,
},
重置表单时富文本没有重置
org.apache.ibatis.binding.BindingException
Invalid bound statement (not found): com.example.serviceedu.mapper.EduCourseMapper.selectCoursePublishVoById
AbstractHandlerExceptionResolver.java:194 |org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver |Resolved exception caused by handler execution: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.guli.edu.mapper.CourseMapper.getCoursePublishVoById
原因:
-
Mapper 接口的方法名 与 Mapper接口的映射文件(xxx.xml) 的 id 不一样
-
dao层编译后只有class文件,没有mapper.xml,因为maven工程在默认情况下src/main/java目录下的所有资源文件是不发布到target目录下的,
解决方案:
1、在guli_edu的pom中配置如下节点
<!-- 项目打包时会将java目录中的*.xml文件也进行打包 --> <build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources> </build>
重新打包项目会发现target目录下出现了xml文件夹
2、在Spring Boot配置文件中添加配置
#配置mapper xml文件的路径 mybatis-plus.mapper-locations=classpath:com/guli/edu/mapper/xml/*.xml
Exception in thread “main” com.aliyuncs.exceptions.ClientException: Forbidden.AliyunVoDEncryption
Exception in thread “main” com.aliyuncs.exceptions.ClientException: Forbidden.AliyunVoDEncryption : Currently only the AliyunVoDEncryption stream exists, you must use the Aliyun player to play or set the value of ResultType to Multiple.
原因: 试图获取加密视频的地址
解决: 换一个没有加密的文件就可以了
FileSizeLimitExceededException
Caused by: org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1048576 bytes.
文件大小限制超过异常
解决:
在 application.properties
设置上传文件的大小
# 最大上传单个文件大小:默认1M
spring.servlet.multipart.max-file-size=1024MB
# 最大置总上传的数据大小 :默认10M
spring.servlet.multipart.max-request-size=1024MB
413 (Request Entity Too Large)
请求体过大
配置nginx上传文件大小,否则上传时会有 413 (Request Entity Too Large) 异常
打开nginx主配置文件nginx.conf,找到http{},添加
client_max_body_size 1024m;
重启nginx
nginx -s reload
no server available
原因: 引入了服务注册的依赖,没有在启动类添加 @EnableDiscoveryClient
注解
<!--服务注册-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
服务注册的步骤:
①: 配置Nacos客户端的pom依赖
<!--服务注册-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
②: 添加服务配置信息
配置application.properties,在客户端微服务中添加注册Nacos服务的配置信息
# nacos服务地址
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
③: 添加Nacos客户端注解 在客户端微服务启动类中添加注解
@EnableDiscoveryClient
nuxt依赖下载失败,npm WARN Invalid name: “{ { name }}“
找到package.json文件,在里面修改即可