Eclipse安装Jrebel eclipse免重启加载项目

每次修改JAVA文件都需要重新启动项目,加载时间太长,eclipse安装jrebel控件,避免重启项目节省时间。

1、Help->Eclipse Marketplace

在这里插入图片描述

2、搜索jrebel

在这里插入图片描述

3、Help->jrebel->Configuration 配置jrebel

在这里插入图片描述

4、激活jrebel

在这里插入图片描述

5、在红色框中填入

http://jrebel.com.cn/69972f4a-2911-46eb-87ed-7bbb086e4f38
邮箱写自己的邮箱,如果出现过期的情况,把http://jrebel.com.cn/后面的UUID重新生成即可
UUID生成链接
在这里插入图片描述

6、选择要更新的项目

在这里插入图片描述

7、选择要启用的服务

在这里插入图片描述

8、勾选这两个选项

在这里插入图片描述

9、重启启动项目

,Console提示这个则表示启用自动加载jrebel控件成功。
在这里插入图片描述
10、java代码片段

package sharegoo.util;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.MessageFormat;
import java.util.Date;

import org.apache.commons.codec.digest.DigestUtils;
import com.landray.kmss.util.DateUtil;
import com.landray.kmss.util.ResourceUtil;
import com.landray.kmss.util.UserUtil;

//加密
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Random;


/**
 * 单点登录加密工具类
 *
 */
public class SignOnUtil {

	/**
	 * 单点登录地址
	 * 
	 * @return
	 */
	public static String getUrl() {
		String id = getUser().getFdId();// 获取当前登录人的ID
		
		Date date = new Date(); // 获取当前时间戳
		long timestamp2 = date.getTime();
		
		String str = id+"+++++++"+timestamp2;
        String key  = "123kjflkjlnf"; // 秘钥
        String iv  = getIV();
        //加密
        String encryptTextCBC = encrypt(str, key, iv, AES_CBC);
        //解密
        String path = "/iweb?&code="+encryptTextCBC;
		return path;
	}

	/** 加密模式之 ECB,算法/模式/补码方式 */
    private static final String AES_ECB = "AES/ECB/PKCS5Padding";

    /** 加密模式之 CBC,算法/模式/补码方式 */
    private static final String AES_CBC = "AES/CBC/PKCS5Padding";

    /** 加密模式之 CFB,算法/模式/补码方式 */
    private static final String AES_CFB = "AES/CFB/PKCS5Padding";

    /** AES 中的 IV 必须是 16 字节(128位)长 */
    private static final Integer IV_LENGTH = 16;

    /***
     * <h2>空校验</h2>
     * @param str 需要判断的值
     */
    public static boolean isEmpty(Object str) {
        return null == str || "".equals(str);
    }

    /***
     * <h2>String 转 byte</h2>
     * @param str 需要转换的字符串
     */
    public static byte[] getBytes(String str){
        if (isEmpty(str)) {
            return null;
        }

        try {
            return str.getBytes(StandardCharsets.UTF_8);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    /***
     * <h2>初始化向量(IV),它是一个随机生成的字节数组,用于增加加密和解密的安全性</h2>
     */
    public static String getIV(){
        String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for(int i = 0 ; i < IV_LENGTH ; i++){
            int number = random.nextInt(str.length());
            sb.append(str.charAt(number));
        }
        return sb.toString();
    }

    /***
     * <h2>获取一个 AES 密钥规范</h2>
     */
    public static SecretKeySpec getSecretKeySpec(String key){
        SecretKeySpec secretKeySpec = new SecretKeySpec(getBytes(key), "AES");
        return secretKeySpec;
    }

    /**
     * <h2>加密 - 模式 ECB</h2>
     * @param text 需要加密的文本内容
     * @param key 加密的密钥 key
     * */
    public static String encrypt(String text, String key){
        if (isEmpty(text) || isEmpty(key)) {
            return null;
        }

        try {
            // 创建AES加密器
            Cipher cipher = Cipher.getInstance(AES_ECB);

            SecretKeySpec secretKeySpec = getSecretKeySpec(key);

            cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);

            // 加密字节数组
            byte[] encryptedBytes = cipher.doFinal(getBytes(text));

            // 将密文转换为 Base64 编码字符串
            return Base64.getEncoder().encodeToString(encryptedBytes);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * <h2>解密 - 模式 ECB</h2>
     * @param text 需要解密的文本内容
     * @param key 解密的密钥 key
     * */
    public static String decrypt(String text, String key){
        if (isEmpty(text) || isEmpty(key)) {
            return null;
        }

        // 将密文转换为16字节的字节数组
        byte[] textBytes = Base64.getDecoder().decode(text);

        try {
            // 创建AES加密器
            Cipher cipher = Cipher.getInstance(AES_ECB);

            SecretKeySpec secretKeySpec = getSecretKeySpec(key);

            cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);

            // 解密字节数组
            byte[] decryptedBytes = cipher.doFinal(textBytes);

            // 将明文转换为字符串
            return new String(decryptedBytes, StandardCharsets.UTF_8);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * <h2>加密 - 自定义加密模式</h2>
     * @param text 需要加密的文本内容
     * @param key 加密的密钥 key
     * @param iv 初始化向量
     * @param mode 加密模式
     * */
    public static String encrypt(String text, String key, String iv, String mode){
        if (isEmpty(text) || isEmpty(key) || isEmpty(iv)) {
            return null;
        }

        try {
            // 创建AES加密器
            Cipher cipher = Cipher.getInstance(mode);

            SecretKeySpec secretKeySpec = getSecretKeySpec(key);

            cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, new IvParameterSpec(getBytes(iv)));

            // 加密字节数组
            byte[] encryptedBytes = cipher.doFinal(getBytes(text));

            // 将密文转换为 Base64 编码字符串
            return Base64.getEncoder().encodeToString(encryptedBytes);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * <h2>解密 - 自定义加密模式</h2>
     * @param text 需要解密的文本内容
     * @param key 解密的密钥 key
     * @param iv 初始化向量
     * @param mode 加密模式
     * */
    public static String decrypt(String text, String key, String iv, String mode){
        if (isEmpty(text) || isEmpty(key) || isEmpty(iv)) {
            return null;
        }

        // 将密文转换为16字节的字节数组
        byte[] textBytes = Base64.getDecoder().decode(text);

        try {
            // 创建AES加密器
            Cipher cipher = Cipher.getInstance(mode);

            SecretKeySpec secretKeySpec = getSecretKeySpec(key);

            cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec(getBytes(iv)));

            // 解密字节数组
            byte[] decryptedBytes = cipher.doFinal(textBytes);

            // 将明文转换为字符串
            return new String(decryptedBytes, StandardCharsets.UTF_8);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}

11、JSP代码片段

<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ page import="sharegoo.util.SignOnUtil"%>	
<%@ page import="java.net.URLEncoder"%>
<%@ page import="com.landray.kmss.util.StringUtil"%>
<%@ page import="java.io.UnsupportedEncodingException"%>

<%
	//String returnUrl = request.getParameter("returnUrl");
    String pathUrl = "http://www.local.com";
	String url = pathUrl+SignOnUtil.getUrl();
	
	response.sendRedirect(url);
%>

相关推荐

  1. Nginx命令---平滑重新配置

    2023-12-29 06:40:01       31 阅读
  2. ES安全

    2023-12-29 06:40:01       34 阅读
  3. Ubuntu安全方法

    2023-12-29 06:40:01       40 阅读
  4. Rust杀 Shellcode与混淆

    2023-12-29 06:40:01       28 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-29 06:40:01       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-29 06:40:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-29 06:40:01       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-29 06:40:01       20 阅读

热门阅读

  1. Jtti:UNIX管道和重定向功能在系统备份中怎么用

    2023-12-29 06:40:01       38 阅读
  2. 阿里云Alibaba Cloud Linux 3.2104 LTS 64位镜像系统介绍

    2023-12-29 06:40:01       39 阅读
  3. 阿里云SSD云盘和ESSD云盘有什么区别?

    2023-12-29 06:40:01       37 阅读
  4. c++——list实现细节反思

    2023-12-29 06:40:01       34 阅读
  5. 【Bootstrap学习 day2】

    2023-12-29 06:40:01       33 阅读
  6. docker基础

    2023-12-29 06:40:01       31 阅读
  7. C语言 for 循环的所有应用

    2023-12-29 06:40:01       33 阅读
  8. SpringBoot 集成 Kafka消息中间件,Docker安装Kafka环境

    2023-12-29 06:40:01       38 阅读
  9. How to Replace One Character with Another in Bash Script

    2023-12-29 06:40:01       36 阅读
  10. kafka相关面试题及答案

    2023-12-29 06:40:01       24 阅读
  11. 常用的测试工具有10类

    2023-12-29 06:40:01       30 阅读