我想在mysql和spring boot中使用hibernate spatial。我试过但失败了。 application.properties文件在下面给出
df2.groupby(['Survived', 'Pclass']).size().unstack().plot(kind='bar', stacked=True)
但是我在部署时遇到了异常
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;
}
引起:org.hibernate.boot.registry.selector.spi.StrategySelectionException:无法将名称[org.hibernate.spatial.dialect.mysql.MySQLSpatial5InnoDBDialect]解析为策略[org.hibernate.dialect.Dialect] 在org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:113)〜[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
是否存在与版本相关的问题????
答案 0 :(得分:3)
如果我们在运行时匹配您的异常:
引起: org.hibernate.boot.registry.selector.spi.StrategySelectionException: 无法解析名称 [org.hibernate.spatial.dialect.mysql.MySQLSpatial5InnoDBDialect] as 策略[org.hibernate.dialect.Dialect] at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:113) 〜[冬眠核-5.0.12.Final.jar:5.0.12.Final]
源代码为StrategySelectorImpl
:
@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() + "]"
);
}
}
我们知道类加载器无法加载org.hibernate.spatial.dialect.mysql.MySQLSpatial5InnoDBDialect
类。它可能不在类路径中。
我想你应该添加与你的Hibernate版本匹配的hibernate空间依赖。