Wechsel von httpclient zu httpclient5, Fehler in der Java-Datei [geschlossen]Java

Java-Forum
Anonymous
 Wechsel von httpclient zu httpclient5, Fehler in der Java-Datei [geschlossen]

Post by Anonymous »

Code: Select all

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();
}

}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post