[英]DataGrip org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
I am unable to run some basic groovy code with abstraction.我无法使用抽象运行一些基本的 groovy 代码。 I have read thru this link and auto generated pojos and rest controllers from Data Grip.
我已通过此 链接阅读并从 Data Grip 自动生成 pojos 和 rest 控制器。
Simple code snippet of what I tried我尝试过的简单代码片段
class abstract AGenerate {
abstract def getPackageName() ;
abstract def getFileSuffix() ;
abstract def generateClassFiles()
abstract def generate(output, className, fields) ;
def typeMapping = [
(~/(?i)int/) : "Integer",
(~/(?i)bigint/) : "Long",
(~/(?i)float/): "Double", : "Float",
(~/(?i)double|decimal|real/) : "Double",
(~/(?i)datetime|timestamp/) : "java.sql.Timestamp",
(~/(?i)date/) : "java.sql.Date",
(~/(?i)time/) : "java.sql.Time",
(~/(?i)/) : "String"
]
...
package com.companyname.autogenerate ;
import com.intellij.database.model.DasTable
import com.intellij.database.model.ObjectKind
import com.intellij.database.util.Case
import com.intellij.database.util.DasUtil
FILES.chooseDirectoryAndSave("Choose directory", "Choose where to store generated files") { dir ->
SELECTION.filter { it instanceof DasTable && it.getKind() == ObjectKind.TABLE }.each { generateFolderFromTable(it, dir) }
}
class GenerateEntityClass extends AGenerate {
def getFileSuffix() {
return "Entity.java"
}
def getPackageName() {
return "com.sample;" ;
}
...
Notice I have defined a super class AGenerate and then child classes GenerateEntityClass, I get a error when try to run AutoGenerate at the import line itself请注意,我已经定义了一个超级 class AGenerate,然后是子类 GenerateEntityClass,尝试在导入行本身运行 AutoGenerate 时出现错误
import com.intellij.database.model.DasTable
import com.intellij.database.model.ObjectKind
import com.mycompany.autogenerate.GenerateEntityClass
def GenerateEntityClass entityClass = new GenerateEntityClass();
FILES.chooseDirectoryAndSave("Choose directory", "Choose where to store generated files") { dir ->
SELECTION.filter { it instanceof DasTable && it.getKind() == ObjectKind.TABLE }.each { entityClass.generateFolderFromTable(it, dir) }
}
I get an error我收到一个错误
12:06 AM AutoGenerate.groovy: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script24.groovy: 4: unable to resolve class com.companyname.autogenerate.GenerateEntityClass @ line 4, column 1. import com.companyname.autogenerate.GenerateEntityClass;
12:06 AM AutoGenerate.groovy: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script24.groovy: 4: unable to resolve class com.companyname.autogenerate.GenerateEntityClass @ line 4, column 1. import com.companyname.自动生成。生成实体类;
Edit: Folder Structure Project编辑:文件夹结构项目
-->scripts
----->AutoGenerate.groovy (call this from DataGrip)
----->com
-------->companyname
----------->autogenerate
-------------->AGenerate.groovy
-------------->GenerateEntityClass.groovy
-->src
For some reason abstractions dont work.由于某种原因,抽象不起作用。 So I just separated the scripts in different files (ones that change and ones that done) and used a bash script to concat.
所以我只是将脚本分隔在不同的文件中(更改的文件和完成的文件)并使用 bash 脚本进行连接。 For now this should work.
现在这应该工作。 Until someone answers this in a better way this works.
直到有人以更好的方式回答这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.