Não sei se precisa, mas vou colocar o controller e o application.properties que estou usando no projeto.
Controller
@RestController
@RequestMapping("/carros"
public class CarroController {
@Autowired
CarroRepository carroRepository;
@RequestMapping(value = {"", "/"}, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody Iterable<Carro> listCarros() {
Iterable<Carro> carros = carroRepository.findAll();
return carros;
}
@RequestMapping(value = "/busca/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody Carro buscaCarroId(@PathVariable(value = "id" int id ){
Carro carro;
carro = carroRepository.findById(id);
return carro;
}
@RequestMapping(value = "/filtrotipo/{tipo}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody Carro filtroCarroTipo(@PathVariable(value = "tipo" String tipo ){
return null;
}
}
No método filtroCarroTipo pretendo fazer a consulta.
application.properties
spring.datasource.url: jdbc:mysql://localhost/rest_carros
spring.datasource.username=root
spring.datasource.password=12345
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
Obrigrado!