实践问题bug
网页问题
VUE
get请求的参数中带有英文点号,导致的请求错误:
在Spring MVC框架中,会将地址中的最后一个点号截断为后缀名,从而判断其请求消费的内容类型,在不改变此策略的情况下,修改请求方式与地址也能达到正确处理的目标。
如果请求的url中带有含有 英文点号 的参数,如地址、邮箱等,可以在请求方式中最后再加一个点号,或者修改后端的MVC框架策略,或者将 @PathVariable改为@RequestParam
vue中设置 <form @submit.prevent> ,取消表单提交后的默认跳转
如果出现未使用变量报错,这是因为项目中使用eslint校验规范,它要求没用的就不要定义,定义了就要用。 若要关闭该报错,可在package.json中加入以下代码,然后重启项目:
1
2
3
4
5
6
7
8{
....{
...
},
"rules": {
"no-unused-vars": "off",
}
}或者在未使用变量上注释:
1
// eslint-disable-next-line
Nginx
(1)
使用 make upgrade 平滑升级时,最后发生错误:
1 | [root@zzc nginx-1.22.0]# make upgrade |
原因可能是:之前启动nginx主进程实例没有用绝对路径的nginx命令,导致现在给这个进程发送信号没有效果:也就是没有使用 /usr/local/nginx/sbin/nginx 启动,而是通过查找环境变量中那个 nginx 命令启动的, 当平滑升级Nginx 在接收到 USR2 信号时使用 execve() 执行原 Nginx 启动命令行的第一个参数启动新实例时就会报找不到 nginx 可执行文件的错误(execve() 并不会查找 PATH 环境变量)这样子的话没办法进行平滑升级
解决:先杀死当前 nginx主进程,以绝对路径启动nginx,再执行make upgrade后不报错。
1 | kill -QUIT `cat /usr/local/nginx/logs/nginx.pid` |
Springboot
整合Redis
报错信息:
1
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'stringRedisTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'stringRedisTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'stringRedisTemplate' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'redisConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.class]: Unsatisfied dependency expressed through method 'redisConnectionFactory' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lettuceClientResources' defined in class path resource
这里是Controller类报错,不过异常都是一层一层往外抛的,所以一直往下看,会发现是 ‘lettuceClientResources’ 出错了, 如果你的redis连接配置确保正确的话,有可能是你同时引入了netty的依赖,因为 spring-boot-starter-data-redis 中包含 lettuce-core依赖,而 lettuce-core 中又包含一些netty的依赖, 所以,如果你引入的netty依赖和lettuce-core中的不一样,就会出错。
解决: 查看lettuce-core中的netty版本,将自己的netty版本改成一样的。
具体做法:点击spring-boot-starter-data-redis依赖查找lettuce-core,再点进lettuce-core找netty,就可以看到版本号了
如果最后是 ‘redisConnectionFactory’ 报错, 那可能是连接池依赖没有引入, 需要引入该依赖:commons-pool2 ,且版本要对应,不然也会报错(不写版本号,用springboot管理的version就好)。
1 | <!--ommon-pool--> |