Получение неудовлетворенного исключения зависимости. Ошибка создания bean-компонента с именем при переходе с Spring на SJAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Получение неудовлетворенного исключения зависимости. Ошибка создания bean-компонента с именем при переходе с Spring на S

Сообщение Anonymous »

Здравствуйте, я столкнулся с проблемой в моем приложении Spring. Я перехожу с Spring 2.x. до Spring 3.x. и вижу несколько проблем.:

Код: Выделить всё

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'taxCalculator': Unsatisfied dependency expressed through field 'taxService': Error creating bean with name 'vertexService': Unsatisfied dependency expressed through field 'taxServiceInterpreter': Error creating bean with name 'taxServiceInterpreter': Injection of resource dependencies failed
Я просматриваю дорожку стека, и она сужается до этого компонента, который не создается должным образом.

Код: Выделить всё

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'taxService' available
Вот как я это настроил:

Код: Выделить всё

public class TaxServiceInterpreter {

@Autowired
LoggerUtils loggerUtils;

@Resource(name = "taxService")
RestClient restClient;
а затем в классе конфигурации у меня есть это

Код: Выделить всё

@Slf4j
@Configuration
@JsonPropertyOrder
public class BoilerPlateConfig {
@Bean("taxService")
public RestClient retrieveTemplateForTaxService() {
RequestConfig requestConfig = RequestConfig.custom()
.setConnectionRequestTimeout(taxServiceRestCallSocketTimeout, TimeUnit.MILLISECONDS)
.setResponseTimeout(taxServiceRestCallReadTimeout, TimeUnit.MILLISECONDS).build();
CloseableHttpClient httpClient = HttpClientBuilder.create().setConnectionManager(poolingConnectionManager()).setDefaultRequestConfig(requestConfig).build();
HttpComponentsClientHttpRequestFactory factory =  new HttpComponentsClientHttpRequestFactory(httpClient);
return RestClient.builder().requestInterceptor(new RequestResponseLoggingInterceptor()).requestFactory(factory).build();
}
Эта настройка будет работать в более старой версии Spring, в которой раньше она у меня была и использовалась в качестве resttemplate, а не restclient..

Код: Выделить всё

    public RestTemplate retrievetemplateForTaxService() {
RestTemplate restTemplate = new RestTemplateBuilder().requestFactory(this::clientHttpRequestFactoryTaxService)
.build();
restTemplate.setInterceptors(Collections.singletonList(new RequestResponseLoggingInterceptor()));
return restTemplate;
}

Код: Выделить всё

@Component
public class TaxServiceInterpreter {

@Autowired
LoggerUtils loggerUtils;

@Autowired
RestTemplate restTemplate;
Может ли кто-нибудь указать мне правильное направление, почему он не может найти его с помощью этого тега ресурса?

Подробнее здесь: https://stackoverflow.com/questions/793 ... when-migra
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»