Код: Выделить всё
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
Код: Выделить всё
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestClient;
public class TaxServiceInterpreter {
@Autowired
LoggerUtils loggerUtils;
@Resource(name = "taxService")
RestClient restClient;
Код: Выделить всё
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.core5.util.TimeValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.client.RestClient;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@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();
}
Код: Выделить всё
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