Error Messages:
Generate POJOs. groovy: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script6. groovy: 29: unable to resolve class FileDemo @ line 29, column 3. new FileDemo(dir, className + ".java"). withPrintWriter { out -> generate(out, className, fields) } ^ 1 error at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:295) at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:914) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:627) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:389) at groovy.lang.GroovyClassLoader.lambda$parseClass$3(GroovyClassLoader.java:332) at org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163) at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:330) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:314) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:257) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getScriptClass(GroovyScriptEngineImpl.java:336) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:153) at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264) in IdeScriptEngineManagerImpl$EngineImpl.lambda$eval$1(IdeScriptEngineManagerImpl.java:246)
Solution: Delete the old script and create a new one as below:
import com.intellij.database.model.DasTable import com.intellij.database.util.Case import com.intellij.database.util.DasUtil /* * Available context bindings: * SELECTION Iterable<DasObject> * PROJECT project * FILES files helper */ packageName = "com.sample;" typeMapping = [ (~/(?i)int/) : "long", (~/(?i)float|double|decimal|real/): "double", (~/(?i)datetime|timestamp/) : "java.sql.Timestamp", (~/(?i)date/) : "java.sql.Date", (~/(?i)time/) : "java.sql.Time", (~/(?i)/) : "String" ] FILES.chooseDirectoryAndSave("Choose directory", "Choose where to store generated files") { dir -> SELECTION.filter { it instanceof DasTable }.each { generate(it, dir) } } def generate(table, dir) { def className = javaName(table.getName(), true) def fields = calcFields(table) new File(dir, className + ".java").withPrintWriter { out -> generate(out, className, fields) } } def generate(out, className, fields) { out.println "package $packageName" out.println "" out.println "" out.println "public class $className {" out.println "" fields.each() { if (it.annos != "") out.println " ${it.annos}" out.println " private ${it.type} ${it.name};" } out.println "" fields.each() { out.println "" out.println " public ${it.type} get${it.name.capitalize()}() {" out.println " return ${it.name};" out.println " }" out.println "" out.println " public void set${it.name.capitalize()}(${it.type} ${it.name}) {" out.println " this.${it.name} = ${it.name};" out.println " }" out.println "" } out.println "}" } def calcFields(table) { DasUtil.getColumns(table).reduce([]) { fields, col -> def spec = Case.LOWER.apply(col.getDataType().getSpecification()) def typeStr = typeMapping.find { p, t -> p.matcher(spec).find() }.value fields += [[ name : javaName(col.getName(), false), type : typeStr, annos: ""]] } } def javaName(str, capitalize) { def s = com.intellij.psi.codeStyle.NameUtil.splitNameIntoWords(str) .collect { Case.LOWER.apply(it).capitalize() } .join("") .replaceAll(/[^\p{javaJavaIdentifierPart}[_]]/, "_") capitalize || s.length() == 1? s : Case.LOWER.apply(s[0]) + s[1..-1] }
Read More:
- [Solved] IDEA Compile Lombok to Generate getter/setter Error
- IDEA Maven Fail to Download Dependencies Error: ERROR – #org.jetbrains.idea.maven – Cannot reconnect.
- IDEA was Filed to Start: error launching idea (Failed to create JVM )
- Idea create Maven project Error: [error] no longer supports source option 1.5. Please use version 1.6 or higher, and the idea reports an error: error: Java does not support the error of release version 5
- Generate configDataContextRefres Error: Error creating bean with name ‘configDataContextRefresher‘
- [Solved] IDEA: Internal error (java.lang.UnsupportedClassVersionError)
- [Solved] IDEA JPA Custome Query Error: Can‘t resolve symbol ‘Type‘
- [Solved] IDEA2020 Error: Cannot resolve symbol ‘Servlet‘
- [Solved] debug error: cloud netflix. eureka. EurekaDiscoveryClientConfiguration (IDEA package normally)
- Gitee Idea Push Error: Invocation failed Server returned invalid Response. java.lang.RuntimeException
- IDEA Import Servlet Package Error [How to Solve]
- [Solved] IDEA startup Error: Java lang.StackOverflowError
- How to Solve IntelliJ IDEA Error: Cannot determine path to ‘tools.jar‘ library for 17 (C:\Program Files\Java\jd…
- IDEA pom.xml dependency version error [How to Solve]
- IDEA springboot can recognize POM files, but suddenly it can’t reference mven dependencies. Strange things, inexplicable solutions
- [Solved] IDEA error: sun.security.pkcs not found
- [Solved] IDEA Error: Unknown system variable ‘tx_isolation‘ at
- Idea error: (44,22) Java: constant string too long
- [Solved] IDEA try-with-resources Error: AutoCloseable
- [Solved] Idea 2021.3 Maven 3.8.1 Error: Blocked mirror for repositories