Переход с httpclient на httpclient5, ошибки в файле Java [закрыто]JAVA

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

Сообщение Anonymous »

package com.ofs.fsgbu.analytics.runcmd;

import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import com.ofs.fsgbu.analytics.runcmd.utility.AAIRestUtil;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.ofs.fsgbu.analytics.runcmd.interceptor.UserPreferencesInterceptor;

@Configuration
@EnableAsync
@ComponentScan(basePackages = {"com.ofs.aai","com.ofs.fsgbu.analytics.commonlib"})
public class AppConfig implements 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 ... -java-file
Ответить

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

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

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

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

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