【问题标题】:grails throws exception when running grails generate commandsgrails 在运行 grails generate 命令时抛出异常
【发布时间】:2016-04-07 21:19:53
【问题描述】:

我在本地运行 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

我得到了同样的例外。

【问题讨论】:

  • ERROR pool.ConnectionPool - Unable to create initial connections of pool. 在您连接数据库遇到困难时出现。请检查DataSource.groovy中是否所有内容都写得很好
  • 验证URL:jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE 中的 DB url 是否正确。

标签: grails grails-orm


【解决方案1】:

更新:通过将包名附加到 MyClass 来解决此问题,如下所示

grails generate-controller <packagename>.MyClass 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-30
    • 1970-01-01
    • 1970-01-01
    • 2012-09-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多