我有春天啓動的應用程序及以下控制器變遷春季數據REST的基本路徑不涉及定製控制器
@Controller
@RequestMapping("/orders/{id}")
@ExposesResourceFor(Payment.class)
@RequiredArgsConstructor
public class PaymentController {
...
}
當我改變
spring.data.rest.base-path=/api
然後,控制器不帶/ API反應請求基本路徑
curl -i -X PUT -H "Content-Type:application/json" -d "{ \"number\": \"1234123412341234\" }" http://localhost:8080/orders/1/payment
即不是http://localhost:8080/api/orders/1/payment
如果我想擁有/ api基路徑,這意味着更新控制器映射到@RequestMapping("/api/orders/{id}")
這是不可取的,因爲我將配置硬編碼爲代碼。
有沒有解決這個問題的方法? 感謝
這財產是春數據休息控制器RepositoryRestHandlerAdapter。你的控制器是一個標準的Spring MVC控制器。看到這裏進一步討論:http://stackoverflow.com/questions/32927937/how-to-set-base-url-for-rest-in-spring-boot –