【问题标题】:How to use Hibernate Spatial in Grails?如何在 Grails 中使用 Hibernate Spatial?
【发布时间】:2015-07-17 19:00:54
【问题描述】:

我使用 Grails 2.4.5 和 Hibernate 3.6.10.18 并希望在我的 MySql 数据库中使用 Hibernate Spacial

这是我的 BuildConfig.groovy 的一部分:

repositories {
        mavenRepo 'http://download.osgeo.org/webdav/geotools'
        mavenRepo 'http://www.hibernatespatial.org/repository'
}

dependencies {
    test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"

    runtime 'mysql:mysql-connector-java:5.1.36'

    compile 'org.hibernatespatial:hibernate-spatial:1.1.1'
    compile 'org.hibernatespatial:hibernate-spatial-mysql:1.1.1'
    compile 'com.vividsolutions:jts:1.13'
}

刷新依赖可以正常工作。但是当我这样做的时候。 grails run-app 我收到以下错误:

|Running Grails application
Error |
2015-07-17 21:00:05,471 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener  - Error initializing the application: 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': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.mapping.PersistentClass.setJpaEntityName(Ljava/lang/String;)V
Message: 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': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.mapping.PersistentClass.setJpaEntityName(Ljava/lang/String;)V
    Line | Method
->>  266 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run       in java.lang.Thread
Caused by 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': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.mapping.PersistentClass.setJpaEntityName(Ljava/lang/String;)V
->>  266 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run       in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.mapping.PersistentClass.setJpaEntityName(Ljava/lang/String;)V
->>  266 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run       in java.lang.Thread
Caused by NoSuchMethodError: org.hibernate.mapping.PersistentClass.setJpaEntityName(Ljava/lang/String;)V
->>  266 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run       in java.lang.Thread

如何解决此错误?

【问题讨论】:

    标签: mysql hibernate grails


    【解决方案1】:

    找到解决方案here

        compile("org.hibernatespatial:hibernate-spatial:1.1.1") { 
            excludes("hibernate-core") 
            excludes("javassist") 
        } 
        compile("org.hibernatespatial:hibernate-spatial-mysql:1.1.1") { 
            excludes("hibernate-core") 
            excludes("javassist") 
        } 
    

    【讨论】:

      猜你喜欢
      • 2014-11-17
      • 1970-01-01
      • 2015-10-05
      • 2017-07-28
      • 1970-01-01
      • 1970-01-01
      • 2013-01-09
      • 1970-01-01
      • 2013-09-20
      相关资源
      最近更新 更多