импортировать 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;
Код: Выделить всё
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
Мобильная версия