idea之mybatis插件安装注册

MyBatis plugin插件安装步骤(弃用,重新打开失效)

  1. 安装setting->Plugins->Browse Respositories…->MyBatis plugin

  2. 重启

  3. 执行下面代码生成KEY和RESULT

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    import java.security.InvalidKeyException;
    import java.security.KeyPair;
    import java.security.KeyPairGenerator;
    import java.security.NoSuchAlgorithmException;
    import java.security.interfaces.RSAPrivateKey;
    import java.security.interfaces.RSAPublicKey;

    import javax.crypto.BadPaddingException;
    import javax.crypto.Cipher;
    import javax.crypto.IllegalBlockSizeException;
    import javax.crypto.NoSuchPaddingException;

    class Main {

    public static void main(String[] args) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
    KeyPairGenerator keygen = KeyPairGenerator.getInstance("RSA");
    keygen.initialize(512);
    KeyPair kp = keygen.generateKeyPair();
    RSAPrivateKey privateKey = (RSAPrivateKey)kp.getPrivate();
    RSAPublicKey publicKey = (RSAPublicKey)kp.getPublic();
    System.out.println("KEY:\n" + bytesToHexString(publicKey.getEncoded()) + "\n");
    Cipher cipher = Cipher.getInstance("RSA");
    cipher.init(Cipher.ENCRYPT_MODE,privateKey);
    System.out.println("RESULT:\n" + bytesToHexString(cipher.doFinal("ilanyu".getBytes())) + "\n");
    }

    private static String bytesToHexString(byte[] src){
    StringBuilder stringBuilder = new StringBuilder("");
    if (src == null || src.length <= 0) {
    return null;
    }
    for (byte aSrc : src) {
    int v = aSrc & 0xFF;
    String hv = Integer.toHexString(v);
    if (hv.length() < 2) {
    stringBuilder.append(0);
    }
    stringBuilder.append(hv);
    }
    return stringBuilder.toString();
    }
    }
  4. 把key和result填到C:\Users\{用户}\.IntelliJIdea2017.2\config\options\mybatis.xml中对应的字段