我使用 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/