Note that there are some explanatory texts on larger screens.

plurals
  1. POGrails script call my own java classes
    text
    copied!<p>I have just created a grails script to create database, but the code is in Java and I thought I could use that in grails script. </p> <p>This is my script</p> <pre> import com.test.database.* import com.test.constant.* import org.neo4j.kernel.* target(main: "The description of the script goes here!") { db = DataRepository.getInstance(new EmbeddedGraphDatabase( Constant.PROJECT_PATH + "/web-app/WEB-INF/resources/db")) } setDefaultTarget(main) </pre> <p>And my java classes are in src/java, but when I run the script I got this error</p> <pre> Error executing script DbCreate: No such property: DataRepository for class: DbCreate No such property: DataRepository for class: DbCreate at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:387) at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415) at gant.Gant$_dispatch_closure7.doCall(Gant.groovy) at gant.Gant.withBuildListeners(Gant.groovy:427) at gant.Gant.this$2$withBuildListeners(Gant.groovy) at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) at gant.Gant.dispatch(Gant.groovy:415) at gant.Gant.this$2$dispatch(Gant.groovy) at gant.Gant.invokeMethod(Gant.groovy) at gant.Gant.executeTargets(Gant.groovy:590) at gant.Gant.executeTargets(Gant.groovy:589) Caused by: groovy.lang.MissingPropertyException: No such property: DataRepository for class: DbCreate at DbCreate$_run_closure1.doCall(DbCreate:11) at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381) </pre> <p>My question would be could I call user-defined java classes in grails script?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload