diff --git a/build.gradle b/build.gradle index 39a04cf..805a6f9 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ plugins { } group 'com.sjhy' -version '1.2.5-java.RELEASE' +version '1.2.5.RELEASE' sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 diff --git a/src/main/java/com/sjhy/plugin/dto/TableInfoSettingsDTO.java b/src/main/java/com/sjhy/plugin/dto/TableInfoSettingsDTO.java index d5b43f5..60a56ee 100644 --- a/src/main/java/com/sjhy/plugin/dto/TableInfoSettingsDTO.java +++ b/src/main/java/com/sjhy/plugin/dto/TableInfoSettingsDTO.java @@ -95,12 +95,11 @@ public class TableInfoSettingsDTO { return; } DbTable dbTable = tableInfo.getObj(); - PsiClass psiClass = tableInfo.getPsiClassObj(); String key; if (dbTable != null) { key = generateKey(dbTable); - } else if (psiClass != null) { - key = generateKey(psiClass); + } else if (tableInfo.getPsiClassObj() != null) { + key = generateKey((PsiClass) tableInfo.getPsiClassObj()); } else { return; } diff --git a/src/main/java/com/sjhy/plugin/entity/TableInfo.java b/src/main/java/com/sjhy/plugin/entity/TableInfo.java index 7286b6a..169ad13 100644 --- a/src/main/java/com/sjhy/plugin/entity/TableInfo.java +++ b/src/main/java/com/sjhy/plugin/entity/TableInfo.java @@ -2,7 +2,6 @@ package com.sjhy.plugin.entity; import com.fasterxml.jackson.annotation.JsonIgnore; import com.intellij.database.psi.DbTable; -import com.intellij.psi.PsiClass; import lombok.Data; import java.util.List; @@ -24,9 +23,11 @@ public class TableInfo { /** * 原始对象(从实体生成) + * + * Note: 实际类型是com.intellij.psi.PsiClass,为了避免velocity反射出现ClassNotFound,写为Object类型 */ @JsonIgnore - private PsiClass psiClassObj; + private Object psiClassObj; /** * 表名(首字母大写) diff --git a/src/main/java/com/sjhy/plugin/service/impl/CodeGenerateServiceImpl.java b/src/main/java/com/sjhy/plugin/service/impl/CodeGenerateServiceImpl.java index b8eeabe..de41c39 100644 --- a/src/main/java/com/sjhy/plugin/service/impl/CodeGenerateServiceImpl.java +++ b/src/main/java/com/sjhy/plugin/service/impl/CodeGenerateServiceImpl.java @@ -7,6 +7,7 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; +import com.intellij.psi.PsiClass; import com.intellij.util.ReflectionUtil; import com.sjhy.plugin.dict.GlobalDict; import com.sjhy.plugin.dto.GenerateOptions; @@ -80,7 +81,8 @@ public class CodeGenerateServiceImpl implements CodeGenerateService { if (selectedTableInfo.getObj() != null) { Messages.showInfoMessage(selectedTableInfo.getObj().getName() + "表配置信息不正确,请尝试重新配置", GlobalDict.TITLE_INFO); } else if (selectedTableInfo.getPsiClassObj() != null) { - Messages.showInfoMessage(selectedTableInfo.getPsiClassObj().getName() + "类配置信息不正确,请尝试重新配置", GlobalDict.TITLE_INFO); + PsiClass psiClassObj = (PsiClass) selectedTableInfo.getPsiClassObj(); + Messages.showInfoMessage(psiClassObj.getName() + "类配置信息不正确,请尝试重新配置", GlobalDict.TITLE_INFO); } else { Messages.showInfoMessage("配置信息不正确,请尝试重新配置", GlobalDict.TITLE_INFO); } diff --git a/src/main/resources/META-INF/easycode-java.xml b/src/main/resources/META-INF/easycode-java.xml new file mode 100644 index 0000000..9e59791 --- /dev/null +++ b/src/main/resources/META-INF/easycode-java.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index e7549e0..3ccf5ac 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -234,8 +234,7 @@ com.intellij.modules.lang com.intellij.database - - com.intellij.modules.java + com.intellij.modules.java @@ -262,12 +261,6 @@ - - - - -