我在本地运行grails 2.4.4。我有以下域类:
class MyClass {
byte[] posterImage
String posterType
String posterName
static belongsTo = NicheChannel
static constraints = {
posterImage(nullable: true, maxSize: 16384000 /* 16000k */)
posterType(nullable: true)
}
}
当我尝试跑步时
grails generate-controller MyClass
或
grails generate-views MyClass
我得到以下异常:
| Domain class not found in grails-app/domain, trying hibernate mapped classes...
| Error 2016-01-04 04:30:44,365 [main] ERROR pool.ConnectionPool - Unable to create initial connections of pool.
Message: Driver:org.postgresql.Driver@1cce5986 returned null for URL:jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
Line | Method
->> 40 | doCall in _GrailsBootstrap$_run_closure2
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 64 | doCall in _GrailsBootstrap$_run_closure6
| 45 | doCall in _GrailsGenerate_groovy$_run_closure1
^ 40 | doCall in GenerateViews$_run_closure1
| Error 2016-01-04 04:30:44,400 [main] ERROR pool.ConnectionPool - Unable to create initial connections of pool.
Message: Driver:org.postgresql.Driver@269f379b returned null for URL:jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
Line | Method
->> 40 | doCall in _GrailsBootstrap$_run_closure2
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 64 | doCall in _GrailsBootstrap$_run_closure6
| 45 | doCall in _GrailsGenerate_groovy$_run_closure1
^ 40 | doCall in GenerateViews$_run_closure1
| Error 2016-01-04 04:30:44,431 [main] ERROR pool.ConnectionPool - Unable to create initial connections of pool.
Message: Driver:org.postgresql.Driver@20ed4023 returned null for URL:jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
Line | Method
->> 40 | doCall in _GrailsBootstrap$_run_closure2
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 64 | doCall in _GrailsBootstrap$_run_closure6
| 45 | doCall in _GrailsGenerate_groovy$_run_closure1
^ 40 | doCall in GenerateViews$_run_closure1
| Error Error executing script GenerateViews: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: Driver:org.postgresql.Driver@20ed4023 returned null for URL:jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE (Use --stacktrace to see the full trace)
我甚至尝试过
grails generate-all MyClass
我得到同样的例外。
答案 0 :(得分:0)
更新:通过将包名称附加到MyClass进行修复,如下所示
grails generate-controller <packagename>.MyClass