Hello
I have created simple REST endpoint API interface using JAX-RS annotations:
package pl.webservice.cards;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/cards")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public interface CardsServiceApi {
@GET
@Path("/message")
public String getMessage();
}
And its implementation:
package pl.webservice.cards;
public class CardsService implements CardsServiceApi{
@Override
public String getMessage() {
return "Hello World!";
}
}
After sending request in POSTMAN I receive following response:
java.lang.NoSuchMethodException: Could not find a suitable constructor in pl.webservice.cards.CardsServiceApi class.
What is interesting when I "merge" both classes in non-interface class everything works fine. Why?
Thanks for help
Aucun commentaire:
Enregistrer un commentaire