在我的 grails 项目中,我想将公共 jar 文件中的域类与 @grails.persistence.Entity 注释一起使用。但是当我按照 grails 站点的文档中的步骤进行操作时
我添加 hibernate.cfg.xml 喜欢
<!DOCTYPE hibernate-configuration SYSTEM
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<mapping package="com.books" />
<mapping class="com.books.Book" />
</session-factory>
</hibernate-configuration>
到 grails-app/conf/hibernate/ 目录。但是当我启动项目时,它会报告错误日志:
2013-04-11 14:24:53,928 - org.codehaus.groovy.grails.web.context.GrailsContextLoader -20516 [pool-5-thread-1] ERROR - Error executing bootstraps: groovy.lang.MissingMethodException: No signature of method: static com.baoxian.task.inscar.entity.QuoteTask.findById() is applicable for argument types: (java.lang.Long) values: [2851]
Possible solutions: find(), findAll(), findAll(groovy.lang.Closure), find(groovy.lang.Closure)
org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: static com.baoxian.task.inscar.entity.QuoteTask.findById() is applicable for argument types: (java.lang.Long) values: [2851]
Possible solutions: find(), findAll(), findAll(groovy.lang.Closure), find(groovy.lang.Closure)
at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:300)
at grails.util.Environment.executeForEnvironment(Environment.java:293)
at grails.util.Environment.executeForCurrentEnvironment(Environment.java:269)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: groovy.lang.MissingMethodException: No signature of method: static com.baoxian.task.inscar.entity.QuoteTask.findById() is applicable for argument types: (java.lang.Long) values: [2851]
Possible solutions: find(), findAll(), findAll(groovy.lang.Closure), find(groovy.lang.Closure)
at BootStrap$_closure1.doCall(BootStrap.groovy:22)
... 8 more
Disconnected from the target VM, address: '127.0.0.1:63383', transport: 'socket'
Process finished with exit code 1
很明显@Entity 不起作用。此外,我的 BuildConfig.groovy 喜欢:
compile ('com.baoxian:baoxian-task-inscar-manager:1.2.5-SNAPSHOT')
{
excludes "org.grails", "org.slf4j", "xml-apis","mysql","org.hibernate","hsqldb","hibernate-annotations","org.quartz-scheduler","org.springframework"
}
com.baoxian:baoxian-task-inscar-manager:1.2.5-SNAPSHOT 就是我的域类所在的位置
这是我第一次在 stackoverflow 上提问。^_^