How to invoke @ControllerAdvice from another project

Viewed 1416

Actually I wrote a global ExceptionHandling using @ControllerAdvice for my Sprint boot project in a separate project, now I want to call it from another project but seems it doesn't work, since it doesn't override the default exceptions.

I'm developing in Java.

Now I want to know how to configure both projects to be able to invoke this global ExceptionHandling class for me from another project. My intention is to use this into several projects.

Thanks inadvance for the help.

2 Answers

I had the same problem. I fixed it by exposing the controller advised class as a @Bean in the config class (class annotated with @SpringBootApplication).

Of course, you need to add the library's pom dependency where your controller advice is.

Related