1.依赖com.github.ulisesbocchiojasypt-spring-boot-starter2.1.02.生成加密账号密码publicclassEncryption{publicstaticvoidmain(String[]args){Stringusername="root";字符串密码=“root”;System.out.println("待加密用户名:"+username);System.out.println("需要加密的密码:"+password);StandardPBEStringEncryptor加密器=newStandardPBEStringEncryptor();encryptor.setAlgorithm("PBEWithMD5AndDES");//这个是加密方式,使用MD5和DES对称加密encryptor.setPassword("root");//这个是盐,盐。增加密文不被破解的概率Stringenc_name=encryptor.encrypt(username);Stringenc_pwd=encryptor.encrypt(密码);System.out.println("加密名称:"+enc_name);System.out.println("加密密码:"+enc_pwd);}}3、配置文件加密server-username=ENC(NMUJ7h1cqq9J7g4Hkn0yag==)server-password=ENC(Er7T1RxNCsAgbXBejhLrrw==)#可以在配置文件中加解密(但是有风险,可以通过jar启动加配置)jasypt.encryptor.password=root4,jar命令添加nohupjava-jar-Djasypt.encryptor.password=root${APP_NAME}>${APP_LOG}2>&1&5,shell命令start#替换jar包路径这里其他代码不用改shxxx.sh[start|stop|restart|status]"exit1}#检查程序是否运行is_exist(){pid=`ps-ef|grep$APP_NAME|grep-vgrep|awk'{print$2}'`#不存在则返回1,存在则返回0if[-z"${pid}"];thenreturn1elsereturn0fi}#startmethodstart(){is_existif[$?-eq0];thenecho"${APP_NAME}已经运行。pid=${pid}"elsenohupjava-jar-Djasypt.encryptor.password=root${APP_NAME}>${APP_LOG}2>&1&fi}#停止方法stop(){is_existif[$?-eq"0"];然后kill-9$pidelseecho"${APP_NAME}isnotrunning"fi}#Outputrunningstatusstatus(){is_existif[$?-当量“0”];然后echo"${APP_NAME}isrunning.Pidis${pid}"elseecho"${APP_NAME}isNOTrunning."fi}#restartrestart(){stopsleep5start}#根据输入的参数,选择执行相应的方法,如果没有输入,则执行指令case"$1"in"start")start;;“停止”)停止;;“状态”)状态;;“重新启动”)重新启动;;*)用法;;esac