一.常见问题 1.前后端时间格式的问题 配置文件中设置时间的格式和时区
2.MyBatis分页插件统计总记录数total失效的问题 检查一下分页插件的配置 选择以下正确的分页插件配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 package com.atguigu.common.config.mp;import com.baomidou.mybatisplus.annotation.DbType;import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;import org.mybatis.spring.annotation.MapperScan;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;@Configuration @MapperScan("com.atguigu.auth.mapper") public class MybatisPlusConfig { @Bean public MybatisPlusInterceptor mybatisPlusInterceptor () { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor (); interceptor.addInnerInterceptor(new PaginationInnerInterceptor (DbType.MYSQL)); return interceptor; } @Bean public ConfigurationCustomizer configurationCustomizer () { return configuration -> configuration.setUseDeprecatedExecutor(false ); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 package com.atguigu.config;import com.baomidou.mybatisplus.core.injector.ISqlInjector;import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;@Configuration public class MpConfig { @Bean public PaginationInterceptor paginationInterceptor () { return new PaginationInterceptor (); } }
3.网关中的路由问题 网关中的路由匹配问题,模糊的路由放在精确的路由前面,容易是精确的路由配置失效
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 spring: cloud: gateway: routes: - id: product_route uri: lb://gulimall-product predicates: - Path=/api/product/** filters: - RewritePath=/api/(?<segment>.*),/$\{segment} - id: admin_route uri: lb://renren-fast predicates: - Path=/api/** filters: - RewritePath=/api/(?<segment>.*),/renren-fast/$\{segment}
4.Docker中部署mysql后SpringBoot连接时提示表不存在 使用Docer启动容器的时候设置忽略大小写,表不存在是因为表名大小写的原因。
方案一:启动的时候加上–lower_case_table_names= 1
1 docker run -p 3306:3306 --name mysql -v /usr/local/docker/mysql/conf:/etc/mysql -v /usr/local/docker/mysql/logs:/var/log/mysql -v /usr/local/docker/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7 --lower_case_table_names= 1
方案二: 修改mysql挂载在宿主机的配置文件
1 2 lower_case_table_names =1
二.细节知识 1.Linux开启/关闭防火墙的命令 1 2 3 4 5 6 7 8 9 10 # 检查防火墙状态: systemctl status firewalld # 开启防火墙 systemctl start firewalld # 关闭防火墙(有时间限制) systemctl stop firewalld # 设置开机禁用防火墙(先执行上面一条命令之后执行此命令,即可永久关闭) systemctl disable firewalld.service # 设置开机启用防火墙 systemctl enable firewalld.service
2.windows查看端口占用情况,杀死端口的命令 1 2 3 4 # 查询被占用的端口号的信息 netstat -ano | findstr "8080" # 根据端口号的PID杀死该端口的进程 其中 17156 是8080端口的PID值 taskkill /pid 17156 /f
3.Linux开启关闭键盘背光灯 1 2 3 4 5 # 不是永久有效的 # 开启键盘背光灯 xset led named "Scroll Lock" # 关闭键盘背光灯 xset -led named "Scroll Lock"
4.关闭Mysql的服务 1 2 3 4 5 6 7 8 9 10 # 查找是否安装了mysql的服务 rpm -qa | grep -i mysql # 查看mysql服务的状态 service mysqld status # 关闭mysql的服务 service mysqld stop # 重启的命令 service mysqld restart # 关闭开机自启动 systemctl disable mysqld
5.前端向后端传递对象数据 传递普通对象参数的写法
params: searchObj
1 2 3 4 5 6 7 getPageList (current,limit,searchObj ){ return request ({ url : `${api_name} /${current} /${limit} ` , method : 'get' , params : searchObj }) }
1 2 3 4 5 6 7 8 9 10 11 @GetMapping("/{page}/{limit}") public Result pageQueryRole (@PathVariable Long page, @PathVariable Integer limit, SysRoleQueryVo sysRoleQueryVo) { Page<SysRole> pageParam = new Page <>(page, limit); LambdaQueryWrapper<SysRole> queryWrapper = new LambdaQueryWrapper <>(); queryWrapper.like(!StringUtils.isEmpty(sysRoleQueryVo.getRoleName()),SysRole::getRoleName, sysRoleQueryVo.getRoleName()); Page<SysRole> sysRolePage = sysRoleService.page(pageParam, queryWrapper); return Result.ok(sysRolePage); }
json格式的传递
data: searchObj
1 2 3 4 5 6 7 add (sysRole ){ return request ({ url : `${api_name} /save` , method : 'post' , data : sysRole }) }
1 2 3 4 5 @PostMapping("/save") public Result save (@RequestBody SysRole sysRole) { boolean isSave = sysRoleService.save(sysRole); return isSave? Result.ok() : Result.fail(); }
6.调整日志的级别 1 2 3 4 logging: level: com.atguigu.gulimall: debug
7.@JsonInclude注解 1 2 @JsonInclude(JsonInclude.Include.NON_EMPTY) private List<CategoryEntity> children;
8.node相关的问题 1 2 3 4 5 6 7 8 # 查看node的版本 node -v # 查看npm的版本 npm -v # 查看npm使用的镜像源(npm镜像源) npm get registry # 设置淘宝镜像源 npm config set registry http://registry.npm.taobao.org