2015-07-17 2 views
2

Я использую Grails 2.4.5 и Hibernate 3.6.10.18 и хочу использовать Hibernate Spacial с моей базой данных MySql.Как использовать Hibernate Spatial в Grails?

Вот часть моего 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-зависимостей работает отлично. Но когда я сделаю. Grails выполнения приложения я получаю следующее сообщение об ошибке:

|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 

Как решить эту ошибку?

ответ

0

Найдено решение 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") 
    }