我刚刚创建了一个 grails 脚本来创建数据库,但是代码是用 Java 编写的,我想我可以在 grails 脚本中使用它。
这是我的脚本
导入 com.test.database.* 导入 com.test.constant.* 导入 org.neo4j.kernel.* target(main: "这里是脚本的描述!") { db = DataRepository.getInstance(new EmbeddedGraphDatabase( 常量.PROJECT_PATH + "/web-app/WEB-INF/resources/db")) } 设置默认目标(主要)
我的 java 类在 src/java 中,但是当我运行脚本时,我得到了这个错误
执行脚本 DbCreate 时出错:没有这样的属性:类的 DataRepository:DbCreate 没有这样的属性:DataRepository 类:DbCreate 在 gant.Gant$_dispatch_closure5.doCall(Gant.groovy:387) 在 gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415) 在 gant.Gant$_dispatch_closure7.doCall(Gant.groovy) 在 gant.Gant.withBuildListeners(Gant.groovy:427) 在 gant.Gant.this$2$withBuildListeners(Gant.groovy) 在 gant.Gant$this$2$withBuildListeners.callCurrent(未知来源) 在 gant.Gant.dispatch(Gant.groovy:415) 在 gant.Gant.this$2$dispatch(Gant.groovy) 在 gant.Gant.invokeMethod(Gant.groovy) 在 gant.Gant.executeTargets(Gant.groovy:590) 在 gant.Gant.executeTargets(Gant.groovy:589) 引起:groovy.lang.MissingPropertyException:没有这样的属性:类的DataRepository:DbCreate 在 DbCreate$_run_closure1.doCall(DbCreate:11) 在 gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
我的问题是我可以在 grails 脚本中调用用户定义的 java 类吗?