我想製作一個簡單的java應用程序,我想使用CRUDREPOSITORY和我自己的存儲庫。我有這樣的:SpringBoot Rest api
@RestController
@Transactional
@ExposesResourceFor(Person.class)
@RequestMapping("/prueba")
public class PersonController {
@RequestMapping(value="/prueba", method=RequestMethod.GET)
public String person(@RequestParam(value="id", defaultValue="1") int id) {
return "hola"+id;
}
}
這樣的:
@RepositoryRestResource
public interface IClientRepository extends CrudRepository<Client, Long> {
}
的問題是,CRUD效果很好,但我不能叫我的本地主機:8080/prueba/prueba,因爲它給出了一個404錯誤。我嘗試了所有,我無法訪問它,請幫助我!
你是如何運行的? – chrylis
作爲Spring Boot應用:) –
當你啓動你的Spring應用程序時,它將列出它從你的控制器和任何自動配置的東西(即@RepositoryRestResource)找到的請求映射。那裏是否有'/ prueba/prueba'的映射? –