idea 启动时报 address already in use

系统开启hyper-v

  1. Disable hyper-v (which will required a couple of restarts)
    dism.exe /Online /Disable-Feature:Microsoft-Hyper-V

  2. When you finish all the required restarts, reserve the port you want so hyper-v doesn’t reserve it back
    netsh int ipv4 add excludedportrange protocol=tcp startport=<端口号> numberofports=1

  3. Re-Enable hyper-V (which will require a couple of restart)
    dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All

when your system is back, you will be able to bind to that port successfully.

 

把端口号改成6942~6991间的任一个数字

Ubuntu 下Mysql 安装时密码问题

1.安装以后没有设置密码

sudo cat /etc/mysql/debian.cnf

通过这个查看mysql的默认用户名和密码

# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = cOrWdhKDBv7LS86s
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = cOrWdhKDBv7LS86s
socket   = /var/run/mysqld/mysqld.sock

2.正常登录mysql,修改密码

 alter user'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
 flush privileges;

3.重新登陆即可

Mysql 根据时间的筛选语句

引用 https://www.cnblogs.com/shuilangyizu/p/8805384.html

--今天

select * from 表名 where to_days(时间字段名) = to_days(now());

--昨天

SELECT * FROM 表名 WHERE TO_DAYS( NOW( ) ) - TO_DAYS( 时间字段名) <= 1
AND TO_DAYS(NOW()) - TO_DAYS(update_time)>0
--本周 SELECT * FROM 表名 WHERE YEARWEEK( date_format( 时间字段名,'%Y-%m-%d' ) ) = YEARWEEK( now() ) ; --本月 SELECT * FROM 表名 WHERE DATE_FORMAT( 时间字段名, '%Y%m' ) = DATE_FORMAT( CURDATE( ) ,'%Y%m' ) --上一个月 SELECT * FROM 表名 WHERE PERIOD_DIFF(date_format(now(),'%Y%m'),date_format(时间字段名,'%Y%m') =1 --本年 SELECT * FROM 表名 WHERE YEAR( 时间字段名 ) = YEAR( NOW( ) ) --上一月 SELECT * FROM 表名 WHERE PERIOD_DIFF( date_format( now( ) , '%Y%m' ) , date_format( 时间字段名, '%Y%m' ) ) =1 --查询本季度数据 select * from `ht_invoice_information` where QUARTER(create_date)=QUARTER(now()); --查询上季度数据 select * from `ht_invoice_information` where QUARTER(create_date)=QUARTER(DATE_SUB(now(),interval 1 QUARTER)); --查询本年数据 select * from `ht_invoice_information` where YEAR(create_date)=YEAR(NOW()); --查询上年数据 select * from `ht_invoice_information` where year(create_date)=year(date_sub(now(),interval 1 year)); --查询当前这周的数据 SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,'%Y-%m-%d')) = YEARWEEK(now()); --查询上周的数据 SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,'%Y-%m-%d')) = YEARWEEK(now())-1; --查询当前月份的数据 select name,submittime from enterprise where date_format(submittime,'%Y-%m')=date_format(now(),'%Y-%m') --查询距离当前现在6个月的数据 select name,submittime from enterprise where submittime between date_sub(now(),interval 6 month) and now(); --查询上个月的数据 select name,submittime from enterprise where date_format(submittime,'%Y-%m')=date_format(DATE_SUB(curdate(), INTERVAL 1 MONTH),'%Y-%m') select * from ` user ` where DATE_FORMAT(pudate, ' %Y%m ' ) = DATE_FORMAT(CURDATE(), ' %Y%m ' ) ; select * from user where WEEKOFYEAR(FROM_UNIXTIME(pudate,'%y-%m-%d')) = WEEKOFYEAR(now()) select * from user where MONTH (FROM_UNIXTIME(pudate, ' %y-%m-%d ' )) = MONTH (now()) select * from [ user ] where YEAR (FROM_UNIXTIME(pudate, ' %y-%m-%d ' )) = YEAR (now()) and MONTH (FROM_UNIXTIME(pudate, ' %y-%m-%d ' )) = MONTH (now()) select * from [ user ] where pudate between 上月最后一天 and 下月第一天 where date(regdate) = curdate(); select * from test where year(regdate)=year(now()) and month(regdate)=month(now()) and day(regdate)=day(now()) SELECT date( c_instime ) ,curdate( ) FROM `t_score` WHERE 1 LIMIT 0 , 30

监听input的输入数字

/**
 * 监听input的数据数字
 * @param count 限制数量
 * @param contentId input/textarea 输入框的id
 * @param limitId 展示数字的span
 */
function initLimit(count, contentId, limitId) {
    var lim = new limit();
    lim.txtNote = document.getElementById(contentId);
    lim.txtLimit = document.getElementById(limitId);
    lim.limitCount = count;
    lim.init();

    function limit() {
        var txtNote;//文本框
        var txtLimit;//提示字数的input
        var limitCount;//限制的字数
        var txtLength;//到达限制时,字符串的长度
        this.init = function () {
            txtNote = this.txtNote;
            txtLimit = this.txtLimit;
            limitCount = this.limitCount;
            txtNote.oninput = function () {
                wordsLimit()
            };
            txtNote.oninput = function () {
                wordsLimit()
            };
            txtLimit.innerText = limitCount;
        };

        function wordsLimit() {
            var noteCount = txtNote.value.length;
            var InPut = document.getElementById(contentId).value.length;
            if (InPut < 1) {
                //document.getElementById("stay").style.display="none";
            }
            if (InPut >= 1) {
                //document.getElementById("stay").style.display="inline";
                //document.getElementById("stay").style.color="green";
            }
            if (InPut > 70) {
                //document.getElementById("stay").style.color="red";
            }
            if (noteCount > limitCount) {
                txtNote.value = txtNote.value.substring(0, limitCount);
                txtLimit.innerText = 0;
            } else {
                txtLimit.innerText = limitCount - noteCount;
            }
            txtLength = txtNote.value.length;//记录每次输入后的长度
        }
    }
}

 

MySql常用语句

mysql分析当前的查询线程

select * from information_schema.`PROCESSLIST` where info is not null;

或者

show processList

 

联表更新

UPDATE tobacco_product AS p, `temp_公司商品维护(通用)` AS t SET p.ONLINE_DATE_YEAR = CONVERT(STR_TO_DATE(t.`入网日期`, “%Y”),int) WHERE p.CIG_UPCS_CD = t.`条包装条形码`

maven项目多模块打包

1.打包指定的模块

打包该模块,同步打包该模块的引用模块

mvn package -pl module_name -Pproduct -am

2.打包基类模块

打包该模块,同步打包引用该模块的模块

mvn package -pl module_name -Pproduct -amd

 

Centos7开启端口

1.开放端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

–zone 作用域

–add-port=80/tcp 添加端口/通讯协议

–permanent 永久生效,否则重启失效

2.常用命令

启动:systemctl start firewalld

关闭:systemctl stop firewalld

重启:firewall-cmd --reload

查看防火墙是否开启的状态,以及开放端口的情况

      systemctl status firewalld.service

      firewall-cmd --list-all 

 

String 字符串替换’*’

/**
     * 实际替换动作
     *
     * @param str str
     * @return
     */
    public static String replaceAction(String str) {
        if(isEmpty(str)){
            return "";
        }
        String afterReplaced = "";
        int nameLength = str.length();
        if (nameLength < 3 && nameLength > 0) {
            if (nameLength == 1) {
                afterReplaced = "*";
            } else {
                afterReplaced = str.substring(0,1)+"*";
            }
        } else {
            Integer num1, num2, num3;
            num2 = (new Double(Math.ceil(new Double(nameLength) / 3))).intValue();
            num1 = (new Double(Math.floor(new Double(nameLength) / 3))).intValue();
            num3 = nameLength - num1 - num2;
            String star = org.apache.commons.lang3.StringUtils.repeat("*", num2);
            afterReplaced = str.replaceAll("(.{" + num1 + "})(.{" + num2 + "})(.{" + num3 + "})", "$1" + star + "$3");
        }
        return afterReplaced;
    }