Bom dia, venho executando os exercícios fielmente como nos vídeos, mas ao chamar a url pelo Postman, não está encontrando o recurso, pois dá o retorno 404.
http://localhost:8085/bytebank-api/v1/cliente
Pelo Swagger está funcionando.
http://localhost:8085/bytebank-api/v1/swagger-ui.html
Aliás, no link abaixo, há uma dúvida que postei há duas semanas que ninguém respondeu e pode estar relacionado. https://cursos.alura.com.br/forum/topico-exibindo-o-contexto-132634
Segue o código relacionado às chamadas que baixei do github das aulas.
/**
* NOTE: This class is auto generated by the swagger code generator program (2.4.17).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
package io.swagger.api;
import io.swagger.model.Cliente;
import io.swagger.annotations.*;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import javax.validation.constraints.*;
import java.util.List;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2020-11-04T17:57:43.990Z")
@Api(value = "cliente", description = "the cliente API")
@RequestMapping(value = "/bytebank-api/v1")
public interface ClienteApi {
@ApiOperation(value = "Cadastra Cliente", nickname = "cadastraCliente", notes = "Cadastra um novo cliente", response = Cliente.class, authorizations = {
@Authorization(value = "BasicAuth")
}, tags={ "Cliente", })
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Cadastro efetuado com sucesso", response = Cliente.class),
@ApiResponse(code = 400, message = "Requisição inválida"),
@ApiResponse(code = 500, message = "Erro interno no servidor") })
@RequestMapping(value = "/cliente",
produces = { "application/json" },
consumes = { "application/json" },
method = RequestMethod.POST)
ResponseEntity<Cliente> cadastraCliente(@ApiParam(value = "" ) @Valid @RequestBody Cliente cliente_);
}
package io.swagger.api;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import io.swagger.annotations.ApiParam;
import io.swagger.customizacao.service.ClienteService;
import io.swagger.customizacao.util.RespostasUtil;
import io.swagger.model.Cliente;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2020-11-04T17:57:43.990Z")
@Controller
public class ClienteApiController implements ClienteApi {
@Autowired
private ClienteService clienteService;
@Autowired
private RespostasUtil respostaUtil;
public ResponseEntity<Cliente> cadastraCliente(@ApiParam(value = "" ) @Valid @RequestBody Cliente cliente_) {
try {
return clienteService.salva(cliente_);
} catch (Exception e) {
return respostaUtil.getErroInternoCliente(clienteService.FALHA_AO_TENTAR_CADASTRAR_UM_CLIENTE);
}
}
}
application.properties
springfox.documentation.swagger.v2.path=/api-docs
server.contextPath=/bytebank-api/v1
server.port=8085
spring.jackson.date-format=io.swagger.RFC3339DateFormat
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
#################### datasource ########################
spring.datasource.username=bytebank_admin
spring.datasource.data-password=bytebank_password
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
#################### configuracoes do HSQLDB ########################
spring.datasource.url=jdbc:hsqldb:file:./database_in_memory/bytebank_db
spring.datasource.driver-class-name=org.hsqldb.jdbcDriver