mysql - 如何在 Grails 中使用 Hibernate Spatial?

标签 mysql hibernate grails

我使用 Grails 2.4.5 和 Hibernate 3.6.10.18 并且想使用 Hibernate Spacial使用我的 MySql 数据库。

这是我的 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'
}

Refresh-dependencies 工作正常。但是当我这样做的时候。 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

我该如何解决这个错误?

最佳答案

找到解决方案 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") 
    } 

关于mysql - 如何在 Grails 中使用 Hibernate Spatial?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31482933/

相关文章:

java - 为什么大多数 hibernate 应用程序都使用序列来生成 id?

grails - 检测浏览器语言以进行自动本地化

mysql - 在 MySQL 中连接具有 NULL 值的同一个表

mysql - 如何在通过 PDO 创建表时将表的排序规则设置为 utf8_persian_ci

php - Codeigniter 3.x - 左连接和显示字段问题

Java大文件保存在数据库中-对象设计

mysql - 错误 1064 : Cannot execute while loop in mysql using variables

java - 无法在 Spring Data Repository 中创建自定义查询方法

java - 无法将 Grails 3.3 与 mysql 数据库连接

grails - 如何使Grails在启动时执行 Controller 方法?