Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 原因:org.hibernate.MappingException:无法确定:org.springframework.data.elasticsearch.core.geo.GeoPoint的类型_Spring Boot_Jhipster_<img Src="//i.stack.imgur.com/A3TTx.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">spring Data Elasticsearch - Fatal编程技术网 spring-data-elasticsearch,Spring Boot,Jhipster,spring Data Elasticsearch" /> spring-data-elasticsearch,Spring Boot,Jhipster,spring Data Elasticsearch" />

Spring boot 原因:org.hibernate.MappingException:无法确定:org.springframework.data.elasticsearch.core.geo.GeoPoint的类型

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

我在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 = "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;