Mysql Hibernate spatial jpa,myql和Spring boot 1.5.7不工作
我想将HibernateSpatial与mysql和SpringBoot一起使用。我试过了,但失败了。 下面给出了application.properties文件Mysql Hibernate spatial jpa,myql和Spring boot 1.5.7不工作,mysql,spring,spring-boot,hibernate-spatial,Mysql,Spring,Spring Boot,Hibernate Spatial,我想将HibernateSpatial与mysql和SpringBoot一起使用。我试过了,但失败了。 下面给出了application.properties文件 spring.datasource.url=jdbc:mysql://localhost:3306/tour_management spring.datasource.username=root spring.datasource.password=admin endpoints.actuator.enabled=true endpo
spring.datasource.url=jdbc:mysql://localhost:3306/tour_management
spring.datasource.username=root
spring.datasource.password=admin
endpoints.actuator.enabled=true
endpoints.info.enabled=true
spring.jpa.properties.hibernate.dialect =
org.hibernate.spatial.dialect.mysql.MySQLSpatial5InnoDBDialect
spring.jpa.database-platform =
org.hibernate.spatial.dialect.mysql.MySQLSpatial5InnoDBDialect
@Data
@Entity(name = "Place")
public class PlaceEntity extends BaseEntity {
@Id
@GeneratedValue
@Column(name = "ID")
private long id;
@Column(name = "NAME")
private String name;
@Column(name = "CODE")
private String code;
@Column(name = "LONGITUDE")
private Double longitude;
@Column(name = "LATITUDE")
private Double latitude;
@Column(name = "LOCATION",columnDefinition = "geometry(Point,4326)")
private Point location;
}
但我在部署时遇到异常
buildscript {
ext {
springBootVersion = '1.5.7.RELEASE'
}
repositories {
mavenCentral()
maven {
url "http://www.hibernatespatial.org/repository"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-
plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
group = 'com.fm'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven {
url "http://www.hibernatespatial.org/repository"
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('mysql:mysql-connector-java')
compile('org.projectlombok:lombok:1.14.8')
compile('org.springframework.boot:spring-boot-starter-web')
compile('com.vividsolutions:jts:1.13')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
原因:org.hibernate.boot.registry.selector.spi.StrategySelectionException:无法将名称[org.hibernate.spatial.dial.mysql.mysqlspatial5Innodbdial]解析为策略[org.hibernate.dial.dial]
在org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:113)~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
如果我们在运行时匹配您的异常,是否存在与版本相关的问题??: 原因: org.hibernate.boot.registry.selector.spi.StrategySelectionException: 无法解析名称 [org.hibernate.spatial.dial.mysql.mysqlspatial5innodbdial]作为 策略[org.hibernate.dialogue.dialogue] org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:113) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final] 使用
策略选择或mpl
的源代码:
@Override
@SuppressWarnings("unchecked")
public <T> Class<? extends T> selectStrategyImplementor(Class<T> strategy, String name) {
final Map<String,Class> namedStrategyImplementorMap = namedStrategyImplementorByStrategyMap.get( strategy );
if ( namedStrategyImplementorMap != null ) {
final Class registered = namedStrategyImplementorMap.get( name );
if ( registered != null ) {
return (Class<T>) registered;
}
}
try {
return classLoaderService.classForName( name );
}
catch (ClassLoadingException e) {
throw new StrategySelectionException(
"Unable to resolve name [" + name + "] as strategy [" + strategy.getName() + "]"
);
}
}
@覆盖
@抑制警告(“未选中”)
public ClassI添加了hibernate核心、hibernate spatial和hibernate entitymanager jar。然后它部署了,但现在又出现了另一个问题,当我在DB上插入数据时,我得到了以下错误。2017-10-09 03:14:52.343警告6000---[nio-8080-exec-1]o.h.engine.jdbc.spi.SqlExceptionHelper:SQL错误:1416,SQLState:22001 2017-10-09 03:14:52.343错误6000---[nio-8080-exec-1]o.h.engine.jdbc.spi.SqlExceptionHelper:数据截断:无法从发送到几何体字段的数据中获取几何体对象这与初始问题无关。如果问题不混合问题,它会使问题更加可重用。请打开一个新问题并仅显示中的相关代码:插入到数据库中的代码/脚本以及与之相关的实体。