Переход с httpclient на httpclient5, ошибки в JavaJAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Переход с httpclient на httpclient5, ошибки в Java

Сообщение Anonymous »

пакет com.ofs.fsgbu.analytics.runcmd;
импортировать java.security.KeyManagementException;
импортировать java.security.NoSuchAlgorithmException;
импортировать java.time.Duration;
импортировать java.util.ArrayList;
импортировать java.util.List;
импортировать com.ofs.fsgbu.analytics.runcmd.utility.AAIRestUtil;
импортировать org.apache.http.conn.ssl.SSLConnectionSocketFactory;
импортировать org.apache.http.impl.client.CloseableHttpClient;
импорт org.apache.http.impl.client.HttpClients;
импорт org.springframework.beans.factory.annotation.Autowired;
импорт org.springframework.boot.web.client.RestTemplateBuilder;
импорт org.springframework.context.annotation.Bean;
импорт org.springframework.context.annotation.ComponentScan;
импорт org.springframework.context.annotation.Configuration;
импорт org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
импорт org.springframework.scheduling.annotation.EnableAsync;
импорт org.springframework.web.client.RestTemplate;
импорт org.springframework.web.servlet.config.annotation.InterceptorRegistry;
импортировать org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
импортировать com.ofs.fsgbu.analytics.runcmd.interceptor.UserPreferencesInterceptor;
@Configuration
@EnableAsync
@ComponentScan(basePackages = {"com.ofs.aai","com.ofs.fsgbu.analytics.commonlib"})
публичный класс AppConfig реализует WebMvcConfigurer{

@Autowired

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

UserPreferencesInterceptor userPreferencesInterceptor;
@Override

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

public void addInterceptors(InterceptorRegistry registry) {

List\ patterns = new ArrayList\();

patterns.add("/rest-api/v1/run-cmd/oracle/sqlplus/");

registry.addInterceptor(userPreferencesInterceptor);

}

@Bean

public RestTemplate restTemplate(RestTemplateBuilder builder) {

SSLConnectionSocketFactory socketFactory = null;

try {

socketFactory = new SSLConnectionSocketFactory(AAIRestUtil.getSSLContext());

} catch (NoSuchAlgorithmException e) {

throw new RuntimeException(e);

} catch (KeyManagementException e) {

throw new RuntimeException(e);

}

CloseableHttpClient httpClient = HttpClients.custom()

.setSSLSocketFactory(socketFactory)

.build();

return builder

.requestFactory(() -\> new HttpComponentsClientHttpRequestFactory(httpClient))

.setConnectTimeout(Duration.ofMillis(3000))

.setReadTimeout(Duration.ofMillis(3000))

.build();

}
}

Подробнее здесь: https://stackoverflow.com/questions/798 ... n-java-fie
Ответить

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

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

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

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

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