Reputation: 368
I'm developing web service using jax-rs. I have configured Application
class. It works fine on default xml format. there is no web.xml file. I want to enable json format support. I have found some solution using web.xml. I want to know if there is any way to enable json format support using jersey-json library without using web.xml.
Upvotes: 0
Views: 240
Reputation: 542
Are you using jackson as your JSON serializer? If so, add it in your application class
@Override
public Set<Class<?>> getClasses() {
final Set<Class<?>> classes = new HashSet<>();
//add all your services
classes.add(JacksonFeature.class);
return classes;
}
And annotate your rest endpoints (Produces, Consumes) with MediaType.APPLICATOIN_JSON wherever you need them. It should work without need of any web.xml
Upvotes: 1