当我没有为它设置控制器时,我得到了localhost:8085 /塘的响应...没有映射到任何地方。
更奇怪的是,当我去localhost:8085 / ponds时,我可以在应用程序中看到它正在执行SQL命令。
我已经在网上搜索了这个_embedded的来源,我发现了一些关于HAL和HATEOS的东西,但是,我并没有在任何地方暗中实现这些。
我已经运行了maven clean install并在终端部署,我看到了:
INFO 16328 --- [main] osdrwRepositoryRestHandlerMapping:映射“{[/ {repository} / {id}],methods = [GET],生成= [application / hal + json || application / json]}”到公共组织.springframework.http.ResponseEntity> org.springframework.data.rest.webmvc.RepositoryEntityController.getItemResource(org.springframework.data.rest.webmvc.RootResourceInformation,java.io.Serializable,org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler ,org.springframework.http.HttpHeaders)抛出org.springframework.web.HttpRequestMethodNotSupportedException
org.springframework.http.ResponseEntity <org.springframework.hateoas.Resource>
这是浏览器中的响应:
{
"_embedded" : {
"ponds" : [ ]
},
"_links" : {
"self" : {
"href" : "http://localhost:8085/ponds"
},
"profile" : {
"href" : "http://localhost:8085/profile/ponds"
}
}
}
几个月前我最后一次使用SpringBoot是好的,如果我试图访问我没有编写控制器的链接/映射/ HTML页面,我会得到一个“找不到页面”页面,而不是响应。
我正在使用Spring Boot 2.0.5.RELEASE
我不明白为什么它会给出回应而不是错误......
所以我评论说:
<!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-data-rest</artifactId>-->
<!--</dependency>-->
响应消失了。我仍然不明白为什么它使用ResponseEntity,或者为什么ResponseEntity实际上返回那个JSON ......
弹簧引导启动数据休息
没有必要依赖。我删除了它。
https://spring.io/guides/gs/accessing-data-rest/
本指南将引导您完成创建通过基于超媒体的RESTful前端访问关系JPA数据的应用程序的过程。