Я разрабатываю программу на основе Spring Shell, для которой требуется пользовательский ResultHandler.
Итак, я попытался определить bean-компонент, который возвращает ResultHandler, затем произошла ошибка, которая выглядит следующим образом:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'utilCommands': Unsatisfied dependency expressed through field 'shell'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'shell' defined in class path resource [org/springframework/shell/SpringShellAutoConfiguration.class]: Unsatisfied dependency expressed through method 'shell' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.shell.result.ResultHandlerConfig': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mainResultHandler': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Multiple ResultHandlers configured for class java.lang.Object: both org.springframework.shell.result.DefaultResultHandler@ba8773 and org.springframework.shell.result.DefaultResultHandler@1176a31
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'shell' defined in class path resource [org/springframework/shell/SpringShellAutoConfiguration.class]: Unsatisfied dependency expressed through method 'shell' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.shell.result.ResultHandlerConfig': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mainResultHandler': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Multiple ResultHandlers configured for class java.lang.Object: both org.springframework.shell.result.DefaultResultHandler@ba8773 and org.springframework.shell.result.DefaultResultHandler@1176a31
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.shell.result.ResultHandlerConfig': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mainResultHandler': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Multiple ResultHandlers configured for class java.lang.Object: both org.springframework.shell.result.DefaultResultHandler@ba8773 and org.springframework.shell.result.DefaultResultHandler@1176a31
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mainResultHandler': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Multiple ResultHandlers configured for class java.lang.Object: both org.springframework.shell.result.DefaultResultHandler@ba8773 and org.springframework.shell.result.DefaultResultHandler@1176a31
Caused by: java.lang.IllegalArgumentException: Multiple ResultHandlers configured for class java.lang.Object: both org.springframework.shell.result.DefaultResultHandler@ba8773 and org.springframework.shell.result.DefaultResultHandler@1176a31
Итак, я решил исключить сканирование org.springframework.shell.result.ResultHandlerConfig с атрибутом exclude аннотации SprintBootApplication. Но это не удалось с сообщением об ошибке ниже:
java.lang.IllegalStateException: The following classes could not be excluded because they are not auto-configuration classes:
- org.springframework.shell.result.ResultHandlerConfig
Что я не прав? Как я могу применить свой собственный ResultHandler к Spring Shell?