我试着将Postgis 2.2和Postgresql 9.5与JPA、postgis9.5方言一起使用。我已经在pom.xml中得到了这里的要求http://www.hibernatespatial.org/documentation/documentation/并且类型被正确导入,但是当我尝试使用几何类型运行程序时,我得到了以下错误:

 2017-05-22 06:53:01.382  INFO 13717 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'testdb2'
 2017-05-22 06:53:01.407  WARN 13717 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [com/beaverkilla/trafficaggregator/Config/ApplicationConfig.class]: Invocation of init method failed; nested exception is java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.spatial.integration.SpatialIntegrator could not be instantiated
 2017-05-22 06:53:01.408  INFO 13717 --- [           main] o.apache.catalina.core.StandardService   : Stopping service Tomcat
 2017-05-22 06:53:01.418  INFO 13717 --- [           main] utoConfigurationReportLoggingInitializer :

 Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
 2017-05-22 06:53:01.423 ERROR 13717 --- [           main] o.s.boot.SpringApplication               : Application startup failed

 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [com/beaverkilla/trafficaggregator/Config/ApplicationConfig.class]: Invocation of init method failed; nested exception is java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.spatial.integration.SpatialIntegrator could not be instantiated
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
 at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
 at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
 at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
 at com.beaverkilla.trafficaggregator.TrafficAggregatorApplication.main(TrafficAggregatorApplication.java:40) [classes/:na]
 Caused by: java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.spatial.integration.SpatialIntegrator could not be instantiated
 at java.util.ServiceLoader.fail(ServiceLoader.java:232) ~[na:1.8.0_131]
 at java.util.ServiceLoader.access$100(ServiceLoader.java:185) ~[na:1.8.0_131]
 at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384) ~[na:1.8.0_131]
 at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404) ~[na:1.8.0_131]
 at java.util.ServiceLoader$1.next(ServiceLoader.java:480) ~[na:1.8.0_131]
 at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.loadJavaServices(ClassLoaderServiceImpl.java:324) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.integrator.internal.IntegratorServiceImpl.<init>(IntegratorServiceImpl.java:40) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.boot.registry.BootstrapServiceRegistryBuilder.build(BootstrapServiceRegistryBuilder.java:213) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.buildBootstrapServiceRegistry(EntityManagerFactoryBuilderImpl.java:365) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:166) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:34) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:165) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:160) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:135) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
 at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353) ~[spring-orm-4.3.8.RELEASE.jar:4.3.8.RELEASE]
 at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:370) ~[spring-orm-4.3.8.RELEASE.jar:4.3.8.RELEASE]
 at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:359) ~[spring-orm-4.3.8.RELEASE.jar:4.3.8.RELEASE]
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
 ... 14 common frames omitted
 Caused by: java.lang.NoClassDefFoundError: org/hibernate/service/spi/BasicServiceInitiator
 at java.lang.Class.getDeclaredConstructors0(Native Method) ~[na:1.8.0_131]
 at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) ~[na:1.8.0_131]
 at java.lang.Class.getConstructor0(Class.java:3075) ~[na:1.8.0_131]
 at java.lang.Class.newInstance(Class.java:412) ~[na:1.8.0_131]
 at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380) ~[na:1.8.0_131]
 ... 30 common frames omitted
 Caused by: java.lang.ClassNotFoundException: org.hibernate.service.spi.BasicServiceInitiator
 at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_131]
 at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_131]
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) ~[na:1.8.0_131]
 at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_131]
 ... 35 common frames omitted

很明显我遗漏了一些配置,有人能指出它是什么吗?

最佳答案

你用的是什么版本的Hibernate?Hibernate4.2适用于HibernateSpatial4.0.1,但是当我升级到使用Hibernate4.3时,我得到了同样的错误。我把Hibernate spatial从4.0.1更新到4.3。

10-04 18:15