Jordi
Jordi

Reputation: 23277

Spring: Activate external RestControllerAdvice

This is a library dependency I'm using into my project:

enter image description here

I'm interested in using GlobalDefaultExceptionHandler into my project. This class is a RestControllerAdvice in intented to handle all exceptions.

However, I don't quite figure out how to activate this advice into my project.

Could you tell me how could I "activate" this advice?

You also can see this library provides an canigo-web-rs.xml file with this content:

<beans xmlns="http://ww...>

     <bean class="cat.gencat.ctti.canigo.arch.web.rs.config.CanigoWebRSConfig"/>

</beans>

I don't know if it can help you to provide some answer.

EDIT

GlobalDefaultExceptionHandler looks like:

@RestControllerAdvice
public final class GlobalDefaultExceptionHandler {...

Upvotes: 0

Views: 501

Answers (2)

cosmos
cosmos

Reputation: 2263

Based on your post, this should do it. I am assuming that CanigoWebRSConfig is configured for the library that matches your need.

@ImportResource({ "classpath:cat/gencat/ctti/canigo/arch/web/rs/config/canigo-web-rs.xml" })
public class AppConfig {
 // This is your application configuration class.
}

Upvotes: 1

Oreste Viron
Oreste Viron

Reputation: 3805

Simple solution :

@RestControllerAdvice
public class MyControllerAdvice extends GlobalDefaultExceptionHandler {}

Upvotes: 1

Related Questions