英文:
Spring 6 PostGIS integration
问题
我一直在尝试将一个使用PostGIS的现有应用程序从Spring 5迁移到Spring 6。
我收到一个错误,提示org.hibernate.spatial.dialect.postgis.PostgisDialect不再可用:
Task :packages:discover-app-back-api:bootRun FAILED
Caused by: org.hibernate.service.spi.ServiceException: 无法创建所请求的服务org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: 无法将名称[org.hibernate.spatial.dialect.postgis.PostgisDialect]解析为策略[org.hibernate.dialect.Dialect]
Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: 无法加载类[org.hibernate.spatial.dialect.postgis.PostgisDialect]
Caused by: java.lang.ClassNotFoundException: 无法加载所请求的类: org.hibernate.spatial.dialect.postgis.PostgisDialect
- Spring boot 3.0.2
- Spring security 6.0.1
- Hibernate 6.1.6
实际上,在版本6.X中不再有这个类。我应该使用什么配置?
英文:
I have been trying to port an existing application using PostGIS from Spring 5 to Spring 6.
I get an error saying that org.hibernate.spatial.dialect.postgis.PostgisDialect is not more available:
> Task :packages:discover-app-back-api:bootRun FAILED
>Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
>Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.spatial.dialect.postgis.PostgisDialect] as strategy [org.hibernate.dialect.Dialect]
>Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.spatial.dialect.postgis.PostgisDialect]
>Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.spatial.dialect.postgis.PostgisDialect
- Spring boot 3.0.2
- Spring security 6.0.1
- Hibernate 6.1.6
Indeed, this class is no more available in the version 6.X.
What configuration should I use?
答案1
得分: 3
不再需要指定方言:
PostgisDialect类首先被PostgisPG9xDialect / PostgisPG10Dialect类替代,但现在这些也已被弃用("不再需要空间方言")。
因此,正确的方言是默认的(org.hibernate.dialect.PostgreSQLDialect)。
但由于它是默认的,不应该在Spring-Boot应用程序中指定它,驱动程序和方言可以从您在spring.datasource.url中指定的内容派生。
英文:
You no longer need to specify the dialect:
The PostgisDialect class was first replaced by PostgisPG9xDialect / PostgisPG10Dialect classes, but now these are also deprecated ("A SpatialDialect is no longer required.").
So the correct dialect is the default (org.hibernate.dialect.PostgreSQLDialect).
But since it is the default it shouldn't be necessary to specify it in your Spring-Boot application, both the default driver and dialect can be derived from what you specify in spring.datasource.url
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论