【发布时间】:2018-08-28 07:36:24
【问题描述】:
我正在使用 SPRING DATA REST 。我有这个控制器。
org.springframework.data.rest.webmvc.RepositoryRestController
import org.springframework.http.HttpMethod
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.http.ResponseEntity
import org.springframework.stereotype.Component
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.ResponseBody
import org.springframework.web.bind.annotation.RestController
@RepositoryRestController
class UserController {
@RequestMapping("/testing")
fun secured(): String {
return "Hello world"
}
@RequestMapping(method = arrayOf(RequestMethod.GET), value = "/scanners")
@ResponseBody
fun getProducers(): ResponseEntity<*> {
return ResponseEntity.ok<Any>("this is just a tedskljdksjdksjkdsjdkskdst")
}
}
我无法访问此端点,我总是得到 404 NOT FOUND,当我更改为 @RestController 时,我可以点击路线。
【问题讨论】:
-
我认为当您没有在配置主类应用程序中使用
@ComponentScan(basePackages =正确包含控制器时,就会出现这种情况。你能检查一下吗?
标签: spring spring-mvc spring-boot spring-data spring-data-jpa