简体   繁体   English

Spring Data Rest中的关联

[英]Association in Spring Data Rest

I have an entity called Veículo and another called Agência , Veículo has many Agência and want to make this association. 我有一个名为Veículo的实体和另一个名为Agência的实体, Veículo有许多Agência并希望建立这种关联。 However, when I try to associate the URI I get this error. 但是,当我尝试关联URI时,我收到此错误。
Can anyone help me on how to associate correctly? 任何人都可以帮我解决如何正确关联?

    daniela.morais@tusk:~$ curl -X POST -H "Content-Type:application/json" -d '{"nome": "Agencia"}' http://localhost:8181/api/agencias
    {
      "nome" : "Agencia",
      "createdBy" : "anonymousUser",
      "lastModifiedBy" : "anonymousUser",
      "createdAt" : "2015-07-17T13:20:10.266+0000",
      "lastModified" : "2015-07-17T13:20:10.266+0000",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8181/api/agencias/55a9010a44ae65cbf03ca4c2"
        }
      }
    }daniela.morais@tusk:~$ curl -X POST -H "Content-Type:application/json" -d '{"nome": "veiculo", "tipo": "tipo"}' http://localhost:8181/api/eiculos
    {
      "nome" : "veiculo",
      "tipo" : "tipo",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8181/api/veiculos/55a9015244ae65cbf03ca4c5"
        },
        "contatos" : {
          "href" : "http://localhost:8181/api/veiculos/55a9015244ae65cbf03ca4c5/contatos"
        },
        "agencias" : {
          "href" : "http://localhost:8181/api/veiculos/55a9015244ae65cbf03ca4c5/agencias"
        }
      }
    }
    daniela.morais@tusk:~$ curl -i -X PUT -H "Content-Type: text/uri-list" -d $'http://localhost:8181/api/agencias/55a9010a44ae65cbf03ca4c2' http://localhost:8181/api/veiculos/55a9015244ae65cbf03ca4c5/agencias
HTTP/1.1 404 Not Found
Server: Apache-Coyote/1.1
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Length: 0
Date: Fri, 17 Jul 2015 13:34:48 GMT
daniela.morais@tusk:~$ curl -X POST -H "Content-Type:application/json" -d '{"nome": "veiculo", "tipo": "tipo"}' http://localhost:8181/api/eiculos

look at this line. 看看这一行。 Should http://localhost:8181/api/eiculos be http://localhost:8181/api/veiculos http://localhost:8181/api/eiculos应该是http://localhost:8181/api/veiculos

or maybe http://localhost:8181/api/veiculos/55a9015244ae65cbf03ca4c5/agencias 或者http://localhost:8181/api/veiculos/55a9015244ae65cbf03ca4c5/agencias

should be http://localhost:8181/api/eiculos/55a9015244ae65cbf03ca4c5/agencias 应该是http://localhost:8181/api/eiculos/55a9015244ae65cbf03ca4c5/agencias

it looks like you've got a misspelling/typo that is causing the 404 看起来你有一个导致404的拼写错误/拼写错误

where eiculos is not veiculos 其中eiculos不是veiculos

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有在Spring Data Rest中获取ManyToOne渴望的关联 - Not fetching ManyToOne eager association in Spring Data Rest Spring Data Rest-关联资源的自链接 - Spring Data Rest - Self link of association resource 在 Spring Data Rest 中放置多对多关联 - PUT on ManyToMany association in Spring Data Rest Spring Data Rest-如何建立关联关系 - Spring Data Rest - How to have an association relationship Spring Data REST - 检测到具有相同关系类型的多个关联链接 - Spring Data REST - Detected multiple association links with same relation type 有没有办法在没有Projection的情况下返回具有id的关联对象 - Is there a way to return association objects with id in spring data rest without Projection Spring Data Rest:检测到具有相同关系类型的多个关联链接 - Spring Data Rest: Detected multiple association links with same relation type 在Spring Data REST中发布@OneToMany子资源关联 - POSTing a @OneToMany sub-resource association in Spring Data REST 当通过关联链接访问时,为什么实体用Spring Data REST封装在内容对象中? - Why is an entity enclosed in a content object with Spring Data REST when accessed via an association link? Spring Data Rest:能够在OneToMany关联中创建子级而无需设置export = false - Spring Data Rest: Ability to create child in OneToMany association without setting exported = false
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM