This may be an impossible task, but here goes...
I think in such cases you would try to add a spring auto configuration that is annotated with
@ConditionalOnClass to be only evaluated if the given class is on the classpath. This class can register the bean and would just be evaluated if the conditional evaluates to true
Here is the relevant part of the spring boot documentation : Creating your own auto-configuration