Spring Boot REST路径,例如个人资料和用户

时间:2018-11-20 07:16:00

标签: spring-boot

我有一个带有以下启动器的Spring Boot应用程序 enter image description here 我需要知道为什么我们有这些REST端点

{
_links: {
users: {
href: "http://localhost:8080/users"
},
profile: { 
href: "http://localhost:8080/profile"
}
}
}

1 个答案:

答案 0 :(得分:1)

这是因为您具有Rest Repositories依赖性。

Spring Docs

  

Spring Data REST为每个导出的文件提供一个应用程序级配置文件语义(ALPS)文档   资料库。它包含有关两个RESTful转换的信息   以及每个存储库的属性。

     

Spring Data REST应用程序的根目录是配置文件链接。假设你   有一个同时包含人员和相关地址的应用程序,即根文档   如下:

{   
   "_links" : {
     "persons" : {
     "href" : "http://localhost:8080/persons"
    },
     "addresses" : {
     "href" : "http://localhost:8080/addresses"
    },
     "profile" : {
     "href" : "http://localhost:8080/profile" 
    }   
  } 
}

/users之所以存在,是因为您可能将其作为端点,或者@marok在注释中已经提到,这是因为UserRepository是以这种方式公开的。

希望有帮助!