How do I register my provider programmatically in jersey which implements the Exceptionmapper provided by jersey API? I don\'t want to use @Provider annotation and want to r
If you're using Spring and want to register the providers programmatically based on the presence of @Path and @Provider annotation you can use the following technique
@Component
public class JerseyConfig extends ResourceConfig {
@Autowired
private ApplicationContext applicationContext;
@PostConstruct
public init() {
applicationContext.getBeansWithAnnotation(Path.class).values().forEach(
component -> register(component.getClass())
);
applicationContext.getBeansWithAnnotation(Provider.class).values().forEach(
this::register
);
}
}