Spring boot 原因:org.hibernate.MappingException:无法确定:org.springframework.data.elasticsearch.core.geo.GeoPoint的类型
我在Spring boot和Spring data elasticsearch项目中有一个Spring boot 原因:org.hibernate.MappingException:无法确定:org.springframework.data.elasticsearch.core.geo.GeoPoint的类型,spring-boot,jhipster,
spring-data-elasticsearch,Spring Boot,Jhipster,
spring Data Elasticsearch,我在Spring boot和Spring data elasticsearch项目中有一个Location实体,其属性类型为org.springframework.data.elasticsearch.core.geo.GeoPoint,如下所示: @Entity @Table(name = "location") @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) @Document(indexName = "locati
Location
实体,其属性类型为org.springframework.data.elasticsearch.core.geo.GeoPoint
,如下所示:
@Entity
@Table(name = "location")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "location")
public class Location implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@NotNull
@Column(name = "name", nullable = false)
private String name;
@NotNull
@Column(name = "country", nullable = false)
private String country;
@GeoPointField
private GeoPoint location;
...
但hibernate抛出
的原因是:org.hibernate.MappingException:启动应用程序时无法确定:org.springframework.data.elasticsearch.core.geo.GeoPoint的类型。有没有办法解决这个问题?我用字符串表示坐标,格式为“12.14,34.53”
(更多)和@GeoPointField
注释,效果很好
@GeoPointField
private String location;
您可以拥有自己的Location类和两个字段,并使用它们
public class Location {
private double lat;
private double lon;
public double getLat() {
return lat;
}
public void setLat(double lat) {
this.lat = lat;
}
public double getLon() {
return lon;
}
public void setLon(double lon) {
this.lon = lon;
}
}
在文档类中,您可以这样使用
@GeoPointField
private Location lastLocation;