31 lines
1.5 KiB
Java
31 lines
1.5 KiB
Java
|
|
package com.example.demo;
|
|||
|
|
|
|||
|
|
import org.springframework.boot.SpringApplication;
|
|||
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
|
|
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
|||
|
|
import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;
|
|||
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|||
|
|
|
|||
|
|
@SpringBootApplication(exclude = {RedisAutoConfiguration.class, RedisRepositoriesAutoConfiguration.class})
|
|||
|
|
@EnableScheduling
|
|||
|
|
public class DemoApplication {
|
|||
|
|
|
|||
|
|
public static void main(String[] args) {
|
|||
|
|
// 在应用启动时立即设置HTTP超时时间(支付宝API调用可能需要更长时间)
|
|||
|
|
// 连接超时:30秒,读取超时:120秒
|
|||
|
|
// 必须在SpringApplication.run()之前设置,确保在所有HTTP客户端创建之前生效
|
|||
|
|
System.setProperty("sun.net.client.defaultConnectTimeout", "30000");
|
|||
|
|
System.setProperty("sun.net.client.defaultReadTimeout", "120000");
|
|||
|
|
|
|||
|
|
// 增加HTTP缓冲区大小以支持大请求体(Base64编码的图片可能很大)
|
|||
|
|
// 设置Socket缓冲区大小为10MB
|
|||
|
|
System.setProperty("java.net.preferIPv4Stack", "true");
|
|||
|
|
// Apache HttpClient 使用系统属性
|
|||
|
|
System.setProperty("org.apache.http.client.connection.timeout", "30000");
|
|||
|
|
System.setProperty("org.apache.http.socket.timeout", "300000");
|
|||
|
|
|
|||
|
|
SpringApplication.run(DemoApplication.class, args);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|