编程的时候经常发现我们需要使用的端口被别的程序占用,这个时候需要清楚查看是哪个程序占用了端口,用且清除了这个进程!

1、开始---->运行---->cmd,或者是window+R组合键,调出命令窗口:

2、输入命令:netstat -ano,列出所有端口的情况。在列表中我们观察被占用的端口,比如是8080,首先找到它:

3、查看被占用端口对应的PID,输入命令:netstat -aon|findstr "8080",回车,记下最后一位数字,即PID,这里是2668。

duan.png

4、继续输入tasklist|findstr "2668",回车,查看是哪个进程或者程序占用了2668端口,结果是:java.exe

5、或者是我们打开任务管理器,点击查看--->选择列,将PID(进程标示符)前面的勾打上,点击确定。

切换到进程选项卡,在PID一列查看2668对应的进程,如下图:

6、结束该进程:在任务管理器中选中该进程点击”结束进程“按钮,或者是在cmd的命令窗口中输入:

taskkill /f /t /im java.exe。

注:后两步可以使用任务管理器,因为看的比较直观而且方便。

命令行工具;可以将下面代码保存为kill.bat文件。双击该文件。出现下方界面。方便快捷

微信截图_20230625082417.png

@echo off & setlocal EnableDelayedExpansion
CHCP 65001
CLS
echo 请输入程序正在运行的端口号
set /p port=
echo 找到的进程记录
echo =================================================================================
netstat -nao|findstr !port!
echo =================================================================================
echo 回车进行逐个确认
pause
for /f "tokens=2,5" %%i in ('netstat -nao^|findstr :%%port%%') do (
    ::if "!processed[%%j]!" == "" (
    if not defined processed[%%j] (
        set pname=N/A
        for /f "tokens=1" %%p in ('tasklist^|findstr %%j') do (set pname=%%p)
        echo %%i    %%j    !pname!
        echo 输入Y确认Kill,否则跳过,可回车跳过
        set flag=N/A
        set /p flag=
        if "!flag!" == "Y" (
            taskkill /pid %%j -t -f
        ) else (
            echo 已跳过
        )
        set processed[%%j]=1
    )
)
echo 程序结束

需求:

element-ui dialog弹窗设置点击空白处不关闭

描述

element-ui dialog弹窗 默认的点击空白处也就是非弹窗区会关闭,这在绝大部分情况下是非常不合适的,会造成弹窗中的数据清空。

我们将该属性改成只能点击右上方叉号关闭。

也就是“:close-on-click-modal” 这个属性设置成false 就可以了

代码

<el-dialog title="添加" :visible.sync="dialogFormVisible" :close-on-click-modal="false">
</el-dialog>

1:项目初始化
@PostConstruct 被注解的方法,在对象加载完依赖注入后执行

@PostConstruct
public void init()
{
    List<SysDictType> dictTypeList = dictTypeMapper.selectDictTypeAll();
    for (SysDictType dictType : dictTypeList)
    {
        List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType());
        DictUtils.setDictCache(dictType.getDictType(), dictDatas);
    }
}

2:我们通常会结合数据库来实现数据字典,但事实上数据字典经常会被使用到,如果频繁地去访问数据库,将会对数据库造成性能压力,事实上我们经常会采用Redis对数据字典进行缓存来提升系统性能

String dictTypeTemp="logistics";
List<SysDictData> data = dictTypeService.selectDictDataByType(dictTypeTemp);

3:在SpringBoot中使用Junit进行Redis的链接测试;基于Ruoyi-Vue

package com.test;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class RedisCon {
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @Test
    public  void setArgs() throws Exception {
        stringRedisTemplate.opsForValue().set("aaa", "111");
        Assert.assertEquals("111", stringRedisTemplate.opsForValue().get("aaa"));
    }
}