0
我有以下控制器:@RepositoryRestController不承認
@RepositoryRestController
public class TestController {
@RequestMapping(value = "/testables", method = RequestMethod.GET)
public String get(){
return "testin it";
}
}
而且它不是由Spring回升。當我點擊/apiroot/testables
地址時,我得到404。如果我將其更改爲@RestController並添加api root來請求映射值,那麼它就可以工作。另外,如果我將映射更改爲指向"/orders/testables"
,則它的工作方式爲@RepositoryRestController
。我也有在同一個包下面控制器的正常工作:
@RepositoryRestController
public class SendEmailController {
@Autowired
private MessageSource messageSource;
@Autowired
private JavaMailSender javaMailSender;
@Autowired
private OrderRepository orderRepository;
@RequestMapping(value = "/orders/{id}/sendOrderEmailToSupplier")
public void sendOrderEmailToSupplier(@PathVariable("id") Long id, WebRequest request) throws MessagingException {...
你是如何設置[basePath](https://docs.spring.io/spring-data/rest/docs/current/reference/html/#_changing_the_base_uri)的? – Cepr0
在'application-default.yml'中,'spring:data:rest:basePath:/ basepath' – aycanadal
很奇怪。在我的測試項目中,所有工作都按預期工使用1.5.4或1.4.3 Spring Boot。 – Cepr0