linux上停止mysql报错的解决办法
linux上停止mysql报错,解决办法有:1、检查错误消息,根据信息提示解决问题;2、查看日志文件,找到导致停止失败的具体错误并解决;3、使用强制停止命令,终止所有与MySQL相关的进程;4、使用kill命令手动杀死MySQL进程;5、确保MySQL相关文件和目录的权限设置正确;6、尝试重启服务器来强制停止MySQL进程。
在 Linux 上停止 MySQL 时遇到错误,可以尝试以下步骤来解决问题:
检查错误消息:当你运行 sudo systemctl stop mysql 或 sudo service mysql stop 命令时,如果遇到错误,系统通常会输出相应的错误消息。请检查错误消息以获取更多信息,这可能有助于确定问题的原因。
查看日志文件:MySQL 通常会将错误和警告消息记录在日志文件中。你可以查看 MySQL 的错误日志文件,通常在 /var/log/mysql 目录下,比如 error.log。通过查看日志文件,你可以找到导致停止失败的具体错误。
使用强制停止命令:如果 MySQL 无法正常停止,你可以尝试使用强制停止命令。首先,使用管理员权限打开终端,并执行以 ...
linux的常用脚本
检测两台服务器指定目录下的文件一致性#!/bin/bash ###################################### 检测两台服务器指定目录下的文件一致性 ##################################### #通过对比两台服务器上文件的md5值,达到检测一致性的目的 dir=/data/web b_ip=192.168.88.10 #将指定目录下的文件全部遍历出来并作为md5sum命令的参数,进而得到所有文件的md5值,并写入到指定文件中 find $dir -type f|xargs md5sum > /tmp/md5_a.txt ssh $b_ip "find $dir -type f|xargs md5sum > /tmp/md5_b.txt" scp $b_ip:/tmp/md5_b.txt /tmp #将文件名作为遍历对象进行一一比对 for f in `awk '{print 2} /tmp/md5_a.txt'`do #以a机器为标 ...
Arrays.asList() 的坑
在Java中,我们经常需要将数组转换为List来方便地进行操作。Arrays.asList()方法是一种常见的方式,但是它存在一个不太常见但需要注意的坑。
Arrays.asList()方法介绍Arrays.asList()方法是将数组转换为List的方法,它返回一个List对象,但这个List对象并不是java.util.ArrayList对象,而是Arrays内部的ArrayList对象。
Arrays.ArrayList类继承自AbstractList,实现了List接口。它重写了add()、remove()等修改List结构的方法,并将它们直接抛出UnsupportedOperationException异常,从而禁止了对List结构的修改。
具体来说,Arrays.asList()方法返回的是Arrays类中的一个私有静态内部类ArrayList,它继承自AbstractList类,实现了List接口。
Arrays.asList()方法的使用非常简单,只需要将一个数组作为参数传递给该方法即可。例如:
String[] arr = new String[]{&quo ...
SpringBoot扫码登录
表这张表就是记录一下谁扫码了。谁登录了。
User_Token表
字段如下:
uuid : 用于确保唯一性
userId :谁登录的
loginTime :登录时间
createTime :创建时间 用于判断是否过期
state:是否二维码失效 0有效 1失效
角色扫码登录这个业务逻辑需要下面这些角色
android端 or 微信Web端 :扫码
PC端 :被扫。登录
服务端:掌控全局,提供接口。
接口接口有2个
生成二维码接口:生成一个二维码。二维码中有UUID。
确认身份接口:确定身份以及判断是否二维码过期等
步骤要把大象装冰箱一共分几步?
PC端打开。调用生成二维码接口 并与 服务端建立链接。链接使用uuid进行绑定
微信Web端进行扫码。获取二维码中的uuid。
微信Web端拿到uuid以后。显示是否登录页面。点击确定后 调用 确认身份接口。
确认身份接口通过以后。服务端给PC端发送信息。完成登录。此时链接断开。
代码二维码获取接口首先需要获取二维码
//获取登录二维码、放入Token @RequestMapping(value = "/getLog ...
随机图片api整理
随机图片api整理的博客收藏
【持续更新】36个二次元、三次元随机图API接口分享及预览
赵苦瓜のblog
SpringBoot开启gzip
在 SpringBoot 中启用 GZIP 压缩打开application.yml文件,添加如下配置
server: compression: enabled: true min-response-size: 1024 # 当返回数据超过这个大小,对返回数据压缩,单位Byte mime-types: application/javascript,text/css,application/json,application/xml,text/html,text/xml,text/plain
在tomcat中开启GZIP压缩打开 Tomcat 的 server.xml,在 Connector 标签中加入下面属性
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" compression="on" compressi ...
xml文件不在resource下时配置方法
在pom中添加build打包的配置
<build> <!--项目打包时会讲java目录中的*.xml文件也进行打包--> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/mapping/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources></build>
在application.properties文件中添加
#配置mapper xml文件寻找的路径#此时xml必须在mapping文件夹下mybatis-plus. ...
mybatis-plus无法使用BaseMapper的公用方法
报错原因:原本的mybatis里面再次引入mybatis-plus之后,使用公用的BaseMapper无法使用报错:也就是无法找到sql,但是可以使用自己编写的sql
解决办法:只需要在你配置数据源的地方,换一个类即可:
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
更改为:
MybatisSqlSessionFactoryBean sessionFactory = new MybatisSqlSessionFactoryBean();
SpringBoot下最全的依赖注入方式
属性注入通过属性注入的方式非常常用,或者说是最常用的
@Servicepublic class UserService { @Autowired private Wolf1Bean wolf1Bean;//通过属性注入}
setter 方法注入除了通过属性注入,通过 setter 方法也可以实现注入:
@Servicepublic class UserService { private Wolf3Bean wolf3Bean; @Autowired //通过setter方法实现注入 public void setWolf3Bean(Wolf3Bean wolf3Bean) { this.wolf3Bean = wolf3Bean; }}
构造器注入当两个类属于强关联时,我们也可以通过构造器的方式来实现注入:
@Servicepublic class UserService { private Wolf2Bean wolf2Bean; @Au ...
RedisTemplate工具类整合
@Componentpublic class RedisUtils { private static RedisTemplate<String, Object> redisTemplate; public RedisUtils(RedisTemplate<String, Object> redisTemplate) { RedisUtils.redisTemplate = redisTemplate; } /** * 判断缓存是否存在 * @param key 缓存key * @return 缓存是否存在 */ public static Boolean hasKey(String key){ return redisTemplate.hasKey(key); } /** * 缓存数据 * @param key 缓存key * @param value 缓存值 */ pub ...
Springboot调用外部http接口的三种方式
https://blog.csdn.net/Chelsea__/article/details/126689495
多线程事务回滚
场景项目需要 导入一批数据,对数据进行切割,用多线程跑。
问题点方法上增加@Transactional,对多线程无效,发生异常,子线程不会回滚,即使在子线程中增加@Transactional。原因:线程不归spring容器管理,也就不指望通知回滚了。
代码将大数据进行切割 // apache自带切割api, num是对应想要切几段ListUtils.partition(list, num);
使用异常标志、发令枪控制各线程回滚@Transactional(rollbackFor = Exception.class)public Result<String> dealData(int sheetMergeCount) { // todo 业务逻辑... // 切割数据 List<List<Integer>> list = splitList(sheetMergeCount, 10); // 异常标志,AtomicBoolean保证线程安全 AtomicBoolean isError = new A ...
OAuth 2.0 第三方登录
OAuth简介OAuth2.0介绍介绍OAuth协议:https://www.rfc-editor.org/rfc/rfc6749
OAuth(Open Authorization)是一个关于授权(authorization)的开放网络标准,允许用户授权第三方 应用访问他们存储在另外的服务提供者上的信息,而不需要将用户名和密码提供给第三方移动应用或分享他 们数据的所有内容。OAuth在全世界得到广泛应用,目前的版本是2.0版。
协议特点:
简单: 不管是OAuth服务提供者还是应用开发者,都很易于理解与使用;
安全: 没有涉及到用户密钥等信息,更安全更灵活;
开放: 任何服务提供商都可以实现OAuth,任何软件开发商都可以使用OAuth;
应用场景
原生app授权: app登录请求后台接口,为了安全认证,所有请求都带token信息,如果登录验证、 请求后台数据
前后端分离单页面应用: 前后端分离框架,前端请求后台数据,需要进行oauth2安全认证
第三方应用授权登录: 比如QQ,微博,微信的授权登录
基本概念OAuth的作用就是让”客户端”安全可控地获取”用户”的授权,与”服务 ...
SpringBoot设置动态定时任务
SpringBoot项目中简单使用定时任务,要借助cron表达式且都提前定义好放在配置文件里,不能在项目运行中动态修改任务执行时间,实在不太灵活。
经过网上搜索学习后,特此记录如何在SpringBoot项目中实现动态定时任务。
因为只是一个demo,所以只引入了需要的依赖:
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-log4j2</artifactId> &l ...
category-line的两种数据类型所绘制图形不同的问题
第一种配置项:xAxis和series的data分开option = { xAxis: { type: 'category', data: ['a','a'] }, yAxis: { type: 'value' }, series: [ { data: [150,150], type: 'line' } ]};
渲染出来的结果:一条横线
第二种配置项:xAxis不设置data,series的data设置为二维数组option = { xAxis: { type: 'category' }, yAxis: { type: 'value' }, series: [ { data: [ ['a& ...
SpringBoot统一登录鉴权、异常处理、数据格式
本篇将要学习 Spring Boot 统一功能处理模块,这也是 AOP 的实战环节
用户登录权限的校验实现接口 HandlerInterceptor + WebMvcConfigurer
异常处理使用注解 @RestControllerAdvice + @ExceptionHandler
数据格式返回使用注解 @ControllerAdvice 并且实现接口 @ResponseBodyAdvice
统一用户登录权限效验用户登录权限的发展完善过程最初用户登录效验:在每个方法中获取 Session 和 Session 中的用户信息,如果存在用户,那么就认为登录成功了,否则就登录失败了第二版用户登录效验:提供统一的方法,在每个需要验证的方法中调用统一的用户登录身份效验方法来判断第三版用户登录效验:使用 Spring AOP 来统一进行用户登录效验第四版用户登录效验:使用 Spring 拦截器来实现用户的统一登录验证
最初用户登录权限效验@RestController@RequestMapping("/user")public class UserController ...
RabbitMq博客整理
SpringBoot 整合 RabbitMQ(注解监听,临时队列)RabbitMQ 可靠性、重复消费、顺序性、消息积压解决方案RabbitMQ:消息丢失 | 消息重复 | 消息积压的原因+解决方案+网上学不到的使用心得
RabbitMq和SpringBoot的整合
介绍该篇文章内容较多,包括有 rabbitMq 相关的一些简单理论介绍,provider 消息推送实例,consumer 消息消费实例,Direct、Topic、Fanout 的使用,消息回调、手动确认等。 (但是关于 rabbitMq 的安装,就不介绍了)
在安装完 rabbitMq 后,输入 http://ip:15672/ ,是可以看到一个简单后台管理界面的。
在这个界面里面我们可以做些什么?可以手动创建虚拟 host,创建用户,分配权限,创建交换机,创建队列等等,还有查看队列消息,消费效率,推送效率等等。
以上这些管理界面的操作在这篇暂时不做扩展描述,我想着重介绍后面实例里会使用到的。
首先先介绍一个简单的一个消息推送到接收的流程,提供一个简单的图:
黄色的圈圈就是我们的消息推送服务,将消息推送到 中间方框里面也就是 rabbitMq 的服务器,然后经过服务器里面的交换机、队列等各种关系(后面会详细讲)将数据处理入列后,最终右边的蓝色圈圈消费者获取对应监听的消息。
常用的交换机有以下三种,因为消费者是从队列获取信息的,队列是绑定交换机的(一般),所以对应的消息推送/接收模式 ...
利用jar命令修改jar包中文件的内容
查找需要修改jar包中的application.yml文件路径[root@test ~]# jar tf test.jar | grep application.ymlBOOT-INF/classes/application.yml
导出jar包中的application.yml文件[root@test ~]# jar xf test.jar BOOT-INF/classes/application.yml[root@test ~]# lldrwxr-xr-x 3 root root 21 6月 28 14:54 BOOT-INF[root@test ~]# tree BOOT-INFBOOT-INF└── classes └── application.yml1 directory, 1 file
修改编辑导出的配置文件[root@test ~]# vim BOOT-INF/classes/application.yml
将修改后的文件重新打入jar包[root@test ~]# jar uf test.jar BOOT-INF/classes/applic ...
8种从spring容器里获取bean的方式
在初始化时保存ApplicationContext对象适用于Spring框架的独立应用程序,须要程序通过配置文件初始化Spring。applicationContext.xml配置:<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&q ...