I'm doing a simple user registration with Java and AngularJS.
My request in javascript looks like this:
$http({
url: "rest/user/register",
method: "POST",
data: $scope.newUser
});
In Java, I have a method that gets the data in a POJO.
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
@Consumes(MediaType.APPLICATION_JSON + ";charset=utf-8")
@POST
@Path("/register")
public String register(UserPojo userPojo){
return "teste";
}
The problem I'm facing is that in the statement of my UserPojo
, I'm being forced to put the @XmlRootElement
annotation to work normally.
If I take the note, the following errors occur:
GRAVE: A message body reader for Java class br.com.taskmanagement.pojo.UserPojo,
and Java type class br.com.taskmanagement.pojo.UserPojo,
and MIME media type application/json; charset=UTF-8 was not found.
The registered message body readers compatible with the MIME media type are:
application/json; charset=UTF-8 ->
I would like to know how to do without @XmlRootElement
, as I'm not sending anything with XML.