RestTemplate没加超时时间,导致的程序卡死

@Component
@Log4j2
public class RestTemplateManager {
    @Autowired
    private RestTemplateBuilder builder;

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private MonitorSettings monitorSettings;

    @Autowired
    private JobManager jobManager;

    @Bean
    public RestTemplate restTemplate() {
        SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
        requestFactory.setConnectTimeout(10000);
        requestFactory.setReadTimeout(10000);

        RestTemplate restTemplate = builder.basicAuthorization("admin", "public").build();
        restTemplate.setRequestFactory(requestFactory);

        return restTemplate;
    }

 

你可能感兴趣的:(RestTemplate没加超时时间,导致的程序卡死)