ilanyu 发布的文章

idea 15 mybatis plus 破解过程

需要修改的是2个文件
mybatis_plus.jarcomseventh7mybatisserviceJavaService.class

mybatis_plus.jarcomseventh7mybatisutilJavaUtils.class

JavaUtils.class
原来的

package com.seventh7.mybatis.util;

import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiAnnotationMemberValue;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiImportList;
import com.intellij.psi.PsiImportStatement;
import com.intellij.psi.PsiJavaFile;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiModifierList;
import com.intellij.psi.PsiModifierListOwner;
import com.intellij.psi.PsiParameter;
import com.intellij.psi.PsiParameterList;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiTreeUtil;
import com.seventh7.mybatis.annotation.Annotation;
import com.seventh7.mybatis.dom.model.IdDomElement;
import com.seventh7.mybatis.generate0.converter.Utils.MLicenseValidator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import net.nicholaswilliams.java.licensing.License;
import net.nicholaswilliams.java.licensing.LicenseManager;
import net.nicholaswilliams.java.licensing.LicenseManagerProperties;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public final class JavaUtils
{
  private JavaUtils()
  {
    throw new UnsupportedOperationException();
  }
  
  public static boolean isModelClazz(@Nullable PsiClass clazz)
  {
    return (null != clazz) && (!clazz.isAnnotationType()) && (!clazz.isInterface()) && (!clazz.isEnum()) && (clazz.isValid());
  }
  
  public static boolean isElementWithinInterface(@Nullable PsiElement element)
  {
    if (((element instanceof PsiClass)) && (((PsiClass)element).isInterface())) {
      return true;
    }
    PsiClass type = (PsiClass)PsiTreeUtil.getParentOfType(element, PsiClass.class);
    return (type != null) && (type.isInterface());
  }
  
  public static List<PsiMethod> findAllMethodsWithoutRootParent(@NotNull PsiClass clazz)
  {
    if (clazz == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "clazz", "com/seventh7/mybatis/util/JavaUtils", "findAllMethodsWithoutRootParent" }));
    }
    Optional<PsiClass> objClazzOpt = findClazz(clazz.getProject(), "java.lang.Object");
    if (!objClazzOpt.isPresent()) {
      return Collections.emptyList();
    }
    PsiClass objClazz = (PsiClass)objClazzOpt.get();
    PsiMethod[] methods = clazz.getAllMethods();
    ArrayList<PsiMethod> res = Lists.newArrayList();
    for (int i = 0; i < methods.length; i++) {
      if (objClazz.findMethodsByName(methods[i].getName(), false).length == 0) {
        res.add(methods[i]);
      }
    }
    return res;
  }
  
  @NotNull
  public static Optional<PsiClass> findClazz(@NotNull Project project, @Nullable String clazzName)
  {
    if (project == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "project", "com/seventh7/mybatis/util/JavaUtils", "findClazz" }));
    }
    Optional tmp65_62 = (clazzName == null ? Optional.absent() : Optional.fromNullable(JavaPsiFacade.getInstance(project).findClass(clazzName, GlobalSearchScope.allScope(project))));
    if (tmp65_62 == null) {
      throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "com/seventh7/mybatis/util/JavaUtils", "findClazz" }));
    }
    return tmp65_62;
  }
  
  @NotNull
  public static Optional<PsiMethod> findMethod(@NotNull Project project, @Nullable String clazzName, @Nullable String methodName)
  {
    if (project == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "project", "com/seventh7/mybatis/util/JavaUtils", "findMethod" }));
    }
    if ((StringUtils.isBlank(clazzName)) && (StringUtils.isBlank(methodName)))
    {
      Optional tmp57_54 = Optional.absent();
      if (tmp57_54 == null) {
        throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "com/seventh7/mybatis/util/JavaUtils", "findMethod" }));
      }
      return tmp57_54;
    }
    Optional<PsiClass> clazz = findClazz(project, clazzName);
    if (clazz.isPresent())
    {
      PsiMethod[] methods = ((PsiClass)clazz.get()).findMethodsByName(methodName, true); Optional 
        tmp142_139 = (ArrayUtils.isEmpty(methods) ? Optional.absent() : Optional.of(methods[0]));
      if (tmp142_139 == null) {
        throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "com/seventh7/mybatis/util/JavaUtils", "findMethod" }));
      }
      return tmp142_139;
    }
    Optional tmp180_177 = Optional.absent();
    if (tmp180_177 == null) {
      throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "com/seventh7/mybatis/util/JavaUtils", "findMethod" }));
    }
    return tmp180_177;
  }
  
  @NotNull
  public static Optional<PsiMethod> findMethod(@NotNull Project project, @NotNull IdDomElement element)
  {
    if (project == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "project", "com/seventh7/mybatis/util/JavaUtils", "findMethod" }));
    }
    if (element == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "element", "com/seventh7/mybatis/util/JavaUtils", "findMethod" }));
    }
    Optional tmp92_89 = findMethod(project, MapperUtils.getNamespace(element), MapperUtils.getId(element));
    if (tmp92_89 == null) {
      throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "com/seventh7/mybatis/util/JavaUtils", "findMethod" }));
    }
    return tmp92_89;
  }
  
  public static boolean isAnnotationPresent(@NotNull PsiModifierListOwner target, @NotNull Annotation annotation)
  {
    if (target == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "target", "com/seventh7/mybatis/util/JavaUtils", "isAnnotationPresent" }));
    }
    if (annotation == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "annotation", "com/seventh7/mybatis/util/JavaUtils", "isAnnotationPresent" }));
    }
    PsiModifierList modifierList = target.getModifierList();
    return (null != modifierList) && (null != modifierList.findAnnotation(annotation.getQualifiedName()));
  }
  
  @NotNull
  public static Optional<PsiAnnotation> getPsiAnnotation(@NotNull PsiModifierListOwner target, @NotNull Annotation annotation)
  {
    if (target == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "target", "com/seventh7/mybatis/util/JavaUtils", "getPsiAnnotation" }));
    }
    if (annotation == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "annotation", "com/seventh7/mybatis/util/JavaUtils", "getPsiAnnotation" }));
    }
    PsiModifierList modifierList = target.getModifierList(); Optional 
      tmp111_108 = (null == modifierList ? Optional.absent() : Optional.fromNullable(modifierList
      .findAnnotation(annotation.getQualifiedName())));
    if (tmp111_108 == null) {
      throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "com/seventh7/mybatis/util/JavaUtils", "getPsiAnnotation" }));
    }
    return tmp111_108;
  }
  
  @NotNull
  public static Optional<PsiAnnotationMemberValue> getAnnotationAttributeValue(@NotNull PsiModifierListOwner target, @NotNull Annotation annotation, @NotNull String attrName)
  {
    if (target == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "target", "com/seventh7/mybatis/util/JavaUtils", "getAnnotationAttributeValue" }));
    }
    if (annotation == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "annotation", "com/seventh7/mybatis/util/JavaUtils", "getAnnotationAttributeValue" }));
    }
    if (attrName == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "attrName", "com/seventh7/mybatis/util/JavaUtils", "getAnnotationAttributeValue" }));
    }
    if (!isAnnotationPresent(target, annotation))
    {
      Optional tmp131_128 = Optional.absent();
      if (tmp131_128 == null) {
        throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "com/seventh7/mybatis/util/JavaUtils", "getAnnotationAttributeValue" }));
      }
      return tmp131_128;
    }
    Optional<PsiAnnotation> psiAnnotation = getPsiAnnotation(target, annotation); Optional 
    
      tmp201_198 = (psiAnnotation.isPresent() ? Optional.fromNullable(((PsiAnnotation)psiAnnotation.get()).findAttributeValue(attrName)) : Optional.absent());
    if (tmp201_198 == null) {
      throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "com/seventh7/mybatis/util/JavaUtils", "getAnnotationAttributeValue" }));
    }
    return tmp201_198;
  }
  
  @NotNull
  public static Optional<PsiAnnotationMemberValue> getAnnotationValue(@NotNull PsiModifierListOwner target, @NotNull Annotation annotation)
  {
    if (target == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "target", "com/seventh7/mybatis/util/JavaUtils", "getAnnotationValue" }));
    }
    if (annotation == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "annotation", "com/seventh7/mybatis/util/JavaUtils", "getAnnotationValue" }));
    }
    Optional tmp90_87 = getAnnotationAttributeValue(target, annotation, "value");
    if (tmp90_87 == null) {
      throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "com/seventh7/mybatis/util/JavaUtils", "getAnnotationValue" }));
    }
    return tmp90_87;
  }
  
  public static Optional<String> getAnnotationValueText(@NotNull PsiModifierListOwner target, @NotNull Annotation annotation)
  {
    if (target == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "target", "com/seventh7/mybatis/util/JavaUtils", "getAnnotationValueText" }));
    }
    if (annotation == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "annotation", "com/seventh7/mybatis/util/JavaUtils", "getAnnotationValueText" }));
    }
    Optional<PsiAnnotationMemberValue> annotationValue = getAnnotationValue(target, annotation);
    return annotationValue.isPresent() ? Optional.of(((PsiAnnotationMemberValue)annotationValue.get()).getText().replaceAll("\"", "")) : Optional.absent();
  }
  
  public static boolean isAnyAnnotationPresent(@NotNull PsiModifierListOwner target, @NotNull Set<Annotation> annotations)
  {
    if (target == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "target", "com/seventh7/mybatis/util/JavaUtils", "isAnyAnnotationPresent" }));
    }
    if (annotations == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "annotations", "com/seventh7/mybatis/util/JavaUtils", "isAnyAnnotationPresent" }));
    }
    for (Annotation annotation : annotations) {
      if (isAnnotationPresent(target, annotation)) {
        return true;
      }
    }
    return false;
  }
  
  public static boolean isAllParameterWithAnnotation(@NotNull PsiMethod method, @NotNull Annotation annotation)
  {
    if (method == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "method", "com/seventh7/mybatis/util/JavaUtils", "isAllParameterWithAnnotation" }));
    }
    if (annotation == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "annotation", "com/seventh7/mybatis/util/JavaUtils", "isAllParameterWithAnnotation" }));
    }
    PsiParameter[] parameters = method.getParameterList().getParameters();
    for (PsiParameter parameter : parameters) {
      if (!isAnnotationPresent(parameter, annotation)) {
        return false;
      }
    }
    return true;
  }
  
  public static boolean hasImportClazz(@NotNull PsiJavaFile file, @Nullable String clazzName)
  {
    if (file == null) {
      throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "file", "com/seventh7/mybatis/util/JavaUtils", "hasImportClazz" }));
    }
    PsiImportList importList = file.getImportList();
    if ((null == importList) || (clazzName == null)) {
      return false;
    }
    PsiImportStatement[] statements = importList.getImportStatements();
    for (PsiImportStatement tmp : statements) {
      if ((null != tmp) && 
        (tmp.getQualifiedName() != null) && 
        (tmp.getQualifiedName().equals(clazzName))) {
        return true;
      }
    }
    return false;
  }
  
  private static boolean valid = false;
  private static boolean validated = false;
  
  public static synchronized boolean refValid()
  {
    if (!validated)
    {
      validated = true;
      try
      {
        License license = getLicense();
        SystemData systemData = SystemData.getInstance();
        String systemMd5 = systemMd5(new String[] { systemData.getCpuId(), systemData
          .getMotherboardId(), systemData
          .getMacAddress() });
        String issuer = license.getIssuer();
        valid = (issuer != null) && (issuer.equals(systemMd5)) && (checkSubject(license.getSubject(), systemData));
      }
      catch (Exception e)
      {
        valid = false;
      }
    }
    return valid;
  }
  
  public static synchronized String systemMd5(String... args)
  {
    return args[2];
  }
  
  private static synchronized boolean checkSubject(String subject, SystemData systemData)
  {
    if (subject == null) {
      return false;
    }
    String[] texts = subject.split("-");
    if (texts.length != 2) {
      return false;
    }
    String[] as1 = texts[0].split("\\.");
    String[] as2 = texts[1].split("\\.");
    String[] idea = systemData.getIdeaBuiltVersion().split("\\.");
    int step = Math.min(Math.min(as1.length, as2.length), idea.length);
    for (int i = 0; i < step; i++)
    {
      int i1 = parseNumber(as1[i]);
      int i2 = parseNumber(as2[i]);
      int i3 = parseNumber(idea[i]);
      if ((i1 == -1) || (i2 == -1) || (i3 == -1)) {
        return false;
      }
      if ((i3 < i1) || (i3 > i2)) {
        return false;
      }
    }
    return true;
  }
  
  private static synchronized int parseNumber(String input)
  {
    return NumberUtils.isNumber(input) ? NumberUtils.toInt(input) : (StringUtils.isNotBlank(input)) && (input.trim().equals("*")) ? Integer.MAX_VALUE : -1;
  }
  
  public static synchronized boolean refNotValid()
  {
    return !refValid();
  }
  
  public static synchronized License getLicense()
    throws Exception
  {
    License l = (License)LICENSE.get();
    if (l != null) {
      return l;
    }
    LicenseManagerProperties.setPublicKeyDataProvider(MapperUtils.publicKeyDataProvider());
    LicenseManagerProperties.setPublicKeyPasswordProvider(MapperUtils.passwordProvider());
    LicenseManagerProperties.setLicenseProvider(MapperUtils.licenseProvider());
    LicenseManagerProperties.setLicenseValidator(new Utils.MLicenseValidator());
    LicenseManager licenseManager = LicenseManager.getInstance();
    License license = licenseManager.getLicense("Ref");
    licenseManager.validateLicense(license);
    
    LICENSE.compareAndSet(null, license);
    
    return license;
  }
  
  private static final AtomicReference<License> LICENSE = new AtomicReference();
  
  public static class SystemData
  {
    private static SystemData instance;
    private final String ip;
    private final String macAddress;
    private final String cpuId;
    private final String motherboardId;
    private final String ideaBuiltVersion;
    private static final String SEP = "|";
    
    public static synchronized SystemData getInstance()
    {
      if (instance == null) {
        instance = new SystemData(NetUtils.getNetIp(), mockMotherboardId(), mockCupId(), mockMotherboardId(), getIdeaVersion());
      }
      return instance;
    }
    
    private SystemData(String ip, String macAddress, String cpuId, String motherboardId, String ideaBuiltVersion)
    {
      this.ip = ip;
      this.macAddress = macAddress;
      this.cpuId = cpuId;
      this.motherboardId = motherboardId;
      this.ideaBuiltVersion = ideaBuiltVersion;
    }
    
    public String getIp()
    {
      return this.ip;
    }
    
    public String getMacAddress()
    {
      return this.macAddress;
    }
    
    public String getCpuId()
    {
      return this.cpuId;
    }
    
    public String getMotherboardId()
    {
      return this.motherboardId;
    }
    
    public String getIdeaBuiltVersion()
    {
      return this.ideaBuiltVersion;
    }
    
    private static String mockMotherboardId()
    {
      StringBuilder buf = new StringBuilder();
      buf.append("is32Bit:").append(SystemInfo.is32Bit).append("|");
      buf.append("is64Bit:").append(SystemInfo.is64Bit).append("|");
      buf.append("isAMD64:").append(SystemInfo.isAMD64).append("|");
      buf.append("isMac:").append(SystemInfo.isMac).append("|");
      buf.append("isWindows:").append(SystemInfo.isWindows).append("|");
      buf.append("isFreeBSD:").append(SystemInfo.isFreeBSD).append("|");
      buf.append("isUnix:").append(SystemInfo.isUnix).append("|");
      buf.append("isMacIntel64:").append(SystemInfo.isMacIntel64).append("|");
      buf.append("isWin7OrNewer:").append(SystemInfo.isWin7OrNewer).append("|");
      buf.append("isFileSystemCaseSensitive:").append(SystemInfo.isFileSystemCaseSensitive).append("|");
      buf.append("isAppleJvm:").append(SystemInfo.isAppleJvm).append("|");
      buf.append("isOracleJvm:").append(SystemInfo.isOracleJvm).append("|");
      buf.append("isSunJvm:").append(SystemInfo.isSunJvm).append("|");
      buf.append("isJetbrainsJvm:").append(SystemInfo.isJetbrainsJvm).append("|");
      buf.append("isFileSystemCaseSensitive:").append(SystemInfo.isAppleJvm).append("|");
      buf.append("osName:").append(SystemInfo.OS_NAME).append("|");
      buf.append("osArch:").append(SystemInfo.OS_ARCH).append("|");
      buf.append("userHome:").append(System.getProperty("user.home")).append("|");
      buf.append("userName:").append(System.getProperty("user.name")).append("|");
      buf.append("areSymLinksSupported:").append(SystemInfo.areSymLinksSupported);
      return buf.toString();
    }
    
    private static String getIdeaVersion()
    {
      return ApplicationInfo.getInstance().getFullVersion();
    }
    
    private static String mockCupId()
    {
      return SystemInfo.OS_NAME;
    }
  }
}




- 阅读剩余部分 -

idea禁用启动图

在启动时添加参数nosplash
如idea.exe nosplash
或者直接修改快捷方式如下图
idea15nosplash.png

看启动图不爽的可以这样修改,不过这样并不会加快启动速度

idea 15 注册方式

安装前修改时间为2099年等很多年后的时间点,安装后选择免费试用30天,然后退出idea,把时间修改回来,这样就可以成功注册了

如果之前使用过授权服务器等激活方式,不弹出试用界面,请到C:Users计算机用户名\.IntelliJIdea15config目录下将idea15.key文件重命名为idea15.key.bak,或者尝试重装idea

在idea中基于maven的springmvc+mybatis框架的demo及搭建教程

初学spring mvc+mybatis,无奈网上各种资料不全,写此文以备份。

1、在idea中安装mybatis插件

插件下载地址http://download.csdn.net/detail/lanyu19950216/9220631,下载后在idea中插件页选择从磁盘安装插件,安装后重启idea即可。

2、mybatis插件的使用

这里https://www.youtube.com/watch?v=Adlp-XuuKAM这个视频录得挺不错的,可以直接看这个视频。

3、在idea中创建新的项目

- 阅读剩余部分 -

一蓑烟雨论坛关站的一些感触

今年8月十多号的时候一蓑烟雨关站
站长原话:

论坛交流的风气几乎完全消灭, 自私的伸手党,把无私分享的高手们赶尽杀绝。

如果大家都不再愿意交流技术, 那就不是论坛, 渐渐地大家都只是来下载,而不愿分享。 这是很可惜的。

也许你会说,【我是菜鸟,我什么都不会,所以没能力分享。】 但是我见到,很多很简单的问题,也没人愿意回答。
大家只是习惯性地维护自己自私的权益。

那些指责我自私的朋友们,扪心自问,论坛开了那么久,你们付出了多少? 如果只因为我们剥夺了你们免费获取前辈们的辛苦成果的途径,
那么我觉得你是没资格批评我们的。

毕竟10年来,我们的付出不会比你少。 论坛的关闭,我们比谁都心疼。 两个月来,每天都睡不着,就为了论坛的前途忧心。

对于那些曾经为论坛无私付出的前辈们, 请接受我们的道歉。 我们已经尽力了。

记得我曾近混过的论坛又何尝不是,我初二开始在艾力克软件工作室接触j2me平台的软件破解、游戏修改等技术,那里有一大堆大牛,toni、程、test等,火星输入法、短信游戏破解插件、翻墙版opera、免流UC、合软工具等原创技术,初三因为艾哥发的三篇php入门资料,开始接触php,也是第一次接触编程,后来因为各种原因,论坛关闭了,看样子以后也不会重开了