定義された半径距離内の地理位置情報のおかげで、オブジェクトのセットを見つける必要があります。
メソッド「findWithinDistance」を実装するために、SpatialRepository クラスを使用して Neo4 J 空間ライブラリを使用しようとしています</p>
オブジェクトの経度と緯度を格納するためのインデックス タイプ POINT を使用した実装に使用されるコードを以下に示します。
@NodeEntity
@TypeAlias(value="MyObject")
public class MyObject{
@GraphId Long nodeId;
private String label;
private String description;
private Double lat;
private Double lon;
@Indexed(indexType = IndexType.POINT, indexName = "locations")
String wkt;
public void setLocation(float longitude, float latitude) {
this.wkt = String.format("POINT( %.2f %.2f )",longitude,longitude);
}
1) 最初の実行では、neo4j データベースにオブジェクトを作成するのに何の問題もありません (neo4j で正しいデータを持つオブジェクトを確認できます)。同じ名前ですが、異なる構成が存在します!
java.lang.IllegalArgumentException: Index with the same name but different config exists!
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'objectRepositoryImpl': Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException:
Could not autowire field: org.springframework.data.neo4j.support.Neo4jTemplate fr.spart.is.neo4j.repository.ObjectRepositoryImpl.template;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'neo4jTemplate'
defined in class org.springframework.data.neo4j.config.Neo4jConfiguration: Instantiation of bean failed;
nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.data.neo4j.support.Neo4jTemplate org.springframework.data.neo4j.config.Neo4jConfiguration.neo4jTemplate()
throws java.lang.Exception] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jMappingContext' defined in class org.springframework.data.neo4j.config.Neo4jConfiguration:
Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Index with the same name but different config exists!
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
findWithinDistance を実装する必要があるメソッドのもう 1 つのポイント: オブジェクトを検索するには、テンプレート メソッドまたは Neo4j Cypher クエリを作成する必要がありますか?
ご協力ありがとうございました、
精度が必要な場合は躊躇しないでください