Spring 6与PostGIS集成

huangapple go评论53阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年2月6日 20:24:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75361767.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定