mirror of
https://gitee.com/wangkang/udf.git
synced 2026-10-28 22:05:14 +00:00
更新
This commit is contained in:
@@ -52,6 +52,30 @@ public class ApplicationConfig {
|
||||
*/
|
||||
private ThreadPoolProperties threadPool;
|
||||
|
||||
/**
|
||||
* 描述 : 如有大文件通过restTemplate传输,请设置为false
|
||||
*/
|
||||
@NotNull
|
||||
private Boolean bufferRequestBody = true;
|
||||
|
||||
/**
|
||||
* 描述 : 获取bufferRequestBody
|
||||
*
|
||||
* @return the bufferRequestBody
|
||||
*/
|
||||
public Boolean getBufferRequestBody() {
|
||||
return bufferRequestBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : 设置bufferRequestBody
|
||||
*
|
||||
* @param bufferRequestBody the bufferRequestBody to set
|
||||
*/
|
||||
public void setBufferRequestBody(Boolean bufferRequestBody) {
|
||||
this.bufferRequestBody = bufferRequestBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : 获取threadPool
|
||||
*
|
||||
|
||||
@@ -6,11 +6,14 @@
|
||||
*/
|
||||
package com.egridcloud.udf.core;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.retry.annotation.EnableRetry;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
@@ -35,6 +38,12 @@ import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
@EnableScheduling
|
||||
public class BaseApplication {
|
||||
|
||||
/**
|
||||
* 描述 : applicationConfig
|
||||
*/
|
||||
@Autowired
|
||||
private ApplicationConfig applicationConfig;
|
||||
|
||||
/**
|
||||
* 描述 : xssObjectMapper
|
||||
*
|
||||
@@ -57,11 +66,24 @@ public class BaseApplication {
|
||||
/**
|
||||
* 描述 : externalRestTemplate
|
||||
*
|
||||
* @param requestFactory requestFactory
|
||||
* @return RestTemplate
|
||||
*/
|
||||
@Bean(name = "externalRestTemplate")
|
||||
public RestTemplate externalRestTemplate() {
|
||||
return new RestTemplate();
|
||||
public RestTemplate externalRestTemplate(ClientHttpRequestFactory requestFactory) {
|
||||
return new RestTemplate(requestFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : requestFactory
|
||||
*
|
||||
* @return ClientHttpRequestFactory
|
||||
*/
|
||||
@Bean
|
||||
public ClientHttpRequestFactory requestFactory() {
|
||||
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
|
||||
requestFactory.setBufferRequestBody(applicationConfig.getBufferRequestBody());
|
||||
return requestFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
@@ -38,12 +39,14 @@ public class RmsConfig {
|
||||
/**
|
||||
* 描述 : restTemplate
|
||||
*
|
||||
* @param requestFactory requestFactory
|
||||
*
|
||||
* @return restTemplate
|
||||
*/
|
||||
@Bean
|
||||
@LoadBalanced
|
||||
RestTemplate restTemplate() {
|
||||
return new RestTemplate();
|
||||
RestTemplate restTemplate(ClientHttpRequestFactory requestFactory) {
|
||||
return new RestTemplate(requestFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user