这是我现在的配置。我想使用休眠空间在生产中使用 postgis。
spring:
profiles: production
datasource:
platform: postgres
url: jdbc:postgresql://192.168.99.100:5432/dragon
username: dragon
password: dragon
database:
driverClassName: org.postgresql.Driver
jpa:
database: POSTGRESQL
database-platform: org.hibernate.spatial.dialect.postgis.PostgisDialect
show-sql: true
hibernate:
ddl-auto: update
---
spring:
profiles: development
datasource: SpatialInMemoryDb
jpa:
database-platform: org.hibernate.spatial.dialect.h2geodb.GeoDBDialect
hibernate:
ddl-auto: create-drop
Run Code Online (Sandbox Code Playgroud)
对于所有发现的测试都是 h2gis 项目。
public class SpatialInMemoryDb extends SingleConnectionDataSource{
public SpatialInMemoryDb() {
setDriverClassName("org.h2.Driver");
setUrl("jdbc:g2:mem:test");
setSuppressClose(true);
}
@Override
public Connection getConnection() throws SQLException {
System.out.println("************");
Connection connection = super.getConnection();
try (Statement st = connection.createStatement()) {
// Import spatial functions, domains and drivers
// …Run Code Online (Sandbox Code Playgroud) spring.jpa.properties.hibernate.dialect=org.hibernate.spatial.dialect.postgis.PostgisDialect
Run Code Online (Sandbox Code Playgroud)
我有一个带有运行 Postgis 数据库的 Hibernate 5 的 Spring Boot v1.5 应用程序。但是,我在空间查询方面遇到了问题,但Invalid endian flag value encountered.. 搜索该异常产生了将适当的 SQL 方言添加到属性文件的解决方案。这样做,如上所述,给我带来了标题中的错误。
直接运行查询psql使它们工作,所以这不是我的 Postgis DB 本身的问题。
这些问题的主题总是拼写错误,但我在这里找不到它会是什么。