在 Grails 中使用 JPA 域类
2022-09-02 04:49:27
我想在使用最新的 Grails 里程碑 (2.0.0.M1) 开发的应用程序中使用 JPA 域模型。JPA 域类位于应用程序的目录中。src\java
基于这篇描述如何在 Grails 应用中使用现有 JPA 域模型的博客文章,我创建了一个 JPA 注释类的列表。grails-app/conf/hibernate/hibernate.cfg.xml
如果有人无聊到想要自己运行该应用程序,则可以在此处获得。运行应用程序时,启动时发生以下错误
Error 2011-08-04 23:28:19,777 [Thread-8] ERROR context.GrailsContextLoader - Error executing bootstraps: Error creati
ng bean with name 'grailsDomainClassMappingContext': Instantiation of bean failed; nested exception is org.springframewo
rk.beans.BeanInstantiationException: Could not instantiate bean class [org.codehaus.groovy.grails.domain.GrailsDomainCla
ssMappingContext]: Constructor threw exception; nested exception is java.lang.NullPointerException
Line | Method
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 138 | run in java.util.concurrent.FutureTask
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run in ''
^ 662 | run . . in java.lang.Thread
Caused by BeanInstantiationException: Could not instantiate bean class [org.codehaus.groovy.grails.domain.GrailsDomainCl
assMappingContext]: Constructor threw exception; nested exception is java.lang.NullPointerException
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 138 | run in java.util.concurrent.FutureTask
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run in ''
^ 662 | run . . in java.lang.Thread
Caused by NullPointerException: null
->> 123 | addPersistentEntityInternal in org.grails.datastore.mapping.model.AbstractMappingContext
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 115 | addPersistentEntity in ''
| 127 | addPersistentEntityInternal in ''
| 115 | addPersistentEntity in ''
| 127 | addPersistentEntityInternal in ''
| 115 | addPersistentEntity in ''
| 303 | innerRun in java.util.concurrent.FutureTask$Sync
| 138 | run in java.util.concurrent.FutureTask
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run in ''
^ 662 | run . . in java.lang.Thread
奇怪的是,这个问题似乎只是由与其他域类有关系的域类触发的。如果删除除(不引用其他域类)之外的所有域类,则应用将启动而不会出错。SystemProperty