Приложение Spring boot выдает «Нет подходящего компонента доступного типа: ожидается как минимум 1 компонент, который соответствует требованиям автоподключения.» ошибка во время выполнения.
Пожалуйста, найдите мой код ниже.
SpringBoot version : 2.7.9
JDK 11
public class CatalogServiceImpl extends CatalogService.CatalogServiceImplBase {
private final DataSourceHandler dataSourceHandlerDelegate;
private final StorefrontServiceHelper storefrontServiceHelper
CatalogServiceImpl ( DataSourceHandler dataSourceHandlerDelegate,
StorefrontServiceHelper storefrontServiceHelper) {
this.dataSourceHandlerDelegate = dataSourceHandlerDelegate;
this.storefrontServiceHelper = storefrontServiceHelper;
}
}
public class StorefrontServiceHelper {
private final CatalogServiceHelper catalogServiceHelper
public StorefrontServiceHelper(CatalogServiceHelper catalogServiceHelper){
this.catalogServiceHelper = catalogServiceHelper;
}
}
public class CatalogServiceHelper {
private final DataSourceHandler dataSourceHandlerDelegate
public CatalogServiceHelper(DataSourceHandler dataSourceHandlerDelegate) {
this.dataSourceHandlerDelegate = dataSourceHandlerDelegate
}
}
public interface DataSourceHandler {
}
public class DataSourceHandlerDelegate implements DataSourceHandler {
public DataSourceHandlerDelegate(DataSourceHandler dynamoDBDataSourceHandler){
this.dynamoDBDataSourceHandler = dynamoDBDataSourceHandler
}
}
public class AppConfig {
@Bean
DataSourceHandlerDelegate
dataSourceHandlerDelegate(@Qualifier("DataSourceHandlerDelegate") DataSourceHandler
dynamoDBDataSourceHandler){
return new DataSourceHandlerDelegate(dynamoDBDataSourceHandler)
}
Ошибка времени выполнения:
2024-10-26 16:20:31,703 [thread="main" class="o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext" cid="" id="" dd_trace_id="" dd_span_id=""] Exception encountered during context initialization cancelling refresh attempt: org.springframework.beans.factory. Unsatisfied Dependency Exception: Error creating bean with name 'catalogServiceImpl' defined in file [item-service/build/classes/java/main/com/item/grpc/CatalogServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory. UnsatisfiedDependencyException: Error creating bean with name 'storefrontServiceHelper' defined in file [item-service/build/classes/java/main/com/item/service/StorefrontServiceHelper.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory. UnsatisfiedDependencyException: Error creating bean with name 'catalogServiceHelper' defined in file [item-service/build/classes/java/main/com/item/service/CatalogServiceHelper.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory. Unsatisfied DependencyException: Error creating bean with name 'dataSourceHandlerDelegate' defined in class path resource [com/item/config/AppConfig.class]: Unsatisfied dependency expressed through method 'dataSourceHandlerDelegate' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com..item.datasource.DataSourceHandler' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation. Qualifier (value="DataSourceHandlerDelegate")}
Подробнее здесь: https://stackoverflow.com/questions/791 ... idate-depe
Java Spring ожидал как минимум 1 bean-компонент, который квалифицируется как кандидат на автоподключение. Аннотации зави ⇐ JAVA
Программисты JAVA общаются здесь
1730061229
Anonymous
Приложение Spring boot выдает «Нет подходящего компонента доступного типа: ожидается как минимум 1 компонент, который соответствует требованиям автоподключения.» ошибка во время выполнения.
Пожалуйста, найдите мой код ниже.
SpringBoot version : 2.7.9
JDK 11
public class CatalogServiceImpl extends CatalogService.CatalogServiceImplBase {
private final DataSourceHandler dataSourceHandlerDelegate;
private final StorefrontServiceHelper storefrontServiceHelper
CatalogServiceImpl ( DataSourceHandler dataSourceHandlerDelegate,
StorefrontServiceHelper storefrontServiceHelper) {
this.dataSourceHandlerDelegate = dataSourceHandlerDelegate;
this.storefrontServiceHelper = storefrontServiceHelper;
}
}
public class StorefrontServiceHelper {
private final CatalogServiceHelper catalogServiceHelper
public StorefrontServiceHelper(CatalogServiceHelper catalogServiceHelper){
this.catalogServiceHelper = catalogServiceHelper;
}
}
public class CatalogServiceHelper {
private final DataSourceHandler dataSourceHandlerDelegate
public CatalogServiceHelper(DataSourceHandler dataSourceHandlerDelegate) {
this.dataSourceHandlerDelegate = dataSourceHandlerDelegate
}
}
public interface DataSourceHandler {
}
public class DataSourceHandlerDelegate implements DataSourceHandler {
public DataSourceHandlerDelegate(DataSourceHandler dynamoDBDataSourceHandler){
this.dynamoDBDataSourceHandler = dynamoDBDataSourceHandler
}
}
public class AppConfig {
@Bean
DataSourceHandlerDelegate
dataSourceHandlerDelegate(@Qualifier("DataSourceHandlerDelegate") DataSourceHandler
dynamoDBDataSourceHandler){
return new DataSourceHandlerDelegate(dynamoDBDataSourceHandler)
}
Ошибка времени выполнения:
2024-10-26 16:20:31,703 [thread="main" class="o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext" cid="" id="" dd_trace_id="" dd_span_id=""] Exception encountered during context initialization cancelling refresh attempt: org.springframework.beans.factory. Unsatisfied Dependency Exception: Error creating bean with name 'catalogServiceImpl' defined in file [item-service/build/classes/java/main/com/item/grpc/CatalogServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory. UnsatisfiedDependencyException: Error creating bean with name 'storefrontServiceHelper' defined in file [item-service/build/classes/java/main/com/item/service/StorefrontServiceHelper.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory. UnsatisfiedDependencyException: Error creating bean with name 'catalogServiceHelper' defined in file [item-service/build/classes/java/main/com/item/service/CatalogServiceHelper.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory. Unsatisfied DependencyException: Error creating bean with name 'dataSourceHandlerDelegate' defined in class path resource [com/item/config/AppConfig.class]: Unsatisfied dependency expressed through method 'dataSourceHandlerDelegate' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com..item.datasource.DataSourceHandler' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation. Qualifier (value="DataSourceHandlerDelegate")}
Подробнее здесь: [url]https://stackoverflow.com/questions/79130754/java-spring-expected-at-least-1-bean-which-qualifies-as-autowire-candidate-depe[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия