0

私はSpringのかなり単純なドメインモデルであると考えています。Springデータの残りNeo4j:テンプレートはnullでも空であってはなりません

@NodeEntity 
class Dependency { 
    @GraphId 
    private Long id 
    String groupId 
    String artifactId 
    String version 

    @Fetch 
    @RelatedTo(type = "DEPENDS_ON", direction = OUTGOING) 
    Set<Dependency> dependencies = new HashSet<Dependency>() 
} 

注*上記はgroovyで書かれています。

私はまた、後続のリポジトリを作成しました(すべてこれまでの教科書!)。私はそれがすべてのオブジェクトと関係を作成することをhttp://127.0.0.1:8080/dependencyで次のペイロードを発射するとき、私は期待

@EnableNeo4jRepositories(basePackages = "io.byteshifter.depsgraph") 
@SpringBootApplication 
class Application extends Neo4jConfiguration { 

    public Application() { 
     setBasePackage("io.byteshifter.depsgraph") 
    } 

    @Bean(destroyMethod = "shutdown") 
    GraphDatabaseService graphDatabaseService() { 
     return new GraphDatabaseFactory().newEmbeddedDatabase("target/dependency.db") 
    } 

    public static void main(String[] args) throws Exception { 
     SpringApplication.run(Application, args) 
    } 
} 

@RepositoryRestResource(collectionResourceRel = "dependency", path = "dependency") 
interface DependencyRepository extends PagingAndSortingRepository<Dependency, Long> { 
    List<Dependency> findByArtifactId(@Param("artifactId") String artifactId) 
} 

そして最後にアプリケーションクラス .... ..

{ 
     "groupId": "group1", 
     "artifactId": "artifact1", 
     "version": "1.0", 
     "dependencies" : [ 
      {"groupId": "group2", "artifactId": "artifact2", "version": "2.0"}, 
      {"groupId": "group3", "artifactId": "artifact3", "version": "3.0"} 
     ] 
} 

代わりに、私は..

{ 
    "cause": { 
    "cause": { 
     "cause": null, 
     "message": "Template must not be null or empty!" 
    }, 
    "message": "Template must not be null or empty! (through reference chain: io.byteshifter.depsgraph.domain.Dependency[\"dependencies\"]->java.util.LinkedHashSet[0])" 
    }, 
    "message": "Could not read JSON: Template must not be null or empty! (through reference chain: io.byteshifter.depsgraph.domain.Dependency[\"dependencies\"]->java.util.LinkedHashSet[0]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Template must not be null or empty! (through reference chain: io.byteshifter.depsgraph.domain.Dependency[\"dependencies\"]->java.util.LinkedHashSet[0])" 
} 

私は疑いもなく、これは私のために理解の欠如です。誰かが正しい方向に私を助けることができれば、それは非常に歓迎されるだろう。

答えて

0

私のRESTの知識が失敗しました。他の依存関係を表すためにURIを使用していたはずです。下記を参照:

{ 
     "groupId": "group3", 
     "artifactId": "artifact3", 
     "version": "1.0", 
     "dependencies": ["http://127.0.0.1:8080/dependency/0", "http://127.0.0.1:8080/dependency/1", "http://127.0.0.1:8080/dependency/2"] 
} 
関連する問題