java110
2022-02-19 30a4683b5af8525df02686f8cdd11d3c27376e2e
优化 拦截器工鞥呢
4个文件已修改
34 ■■■■ 已修改文件
java110-core/pom.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-api/src/main/java/com/java110/api/ApiApplicationStart.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-api/src/main/resources/application-zihao.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-core/pom.xml
@@ -86,8 +86,8 @@
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-okhttp</artifactId>
        </dependency>
    </dependencies>
pom.xml
@@ -213,11 +213,10 @@
                <version>${log4j.version}</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/org.slf4j/log4j-over-slf4j -->
            <dependency>
                <groupId>com.squareup.okhttp3</groupId>
                <artifactId>okhttp</artifactId>
                <version>3.6.0</version>
                <groupId>io.github.openfeign</groupId>
                <artifactId>feign-okhttp</artifactId>
                <version>10.1.0</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
service-api/src/main/java/com/java110/api/ApiApplicationStart.java
@@ -16,16 +16,20 @@
package com.java110.api;
import com.java110.core.annotation.Java110ListenerDiscovery;
import com.java110.core.aop.Java110FeignClientAop;
import com.java110.core.aop.Java110RestTemplateInterceptor;
import com.java110.core.client.RestTemplate;
import com.java110.core.event.service.api.ServiceDataFlowEventPublishing;
import com.java110.core.log.LoggerFactory;
import com.java110.service.init.ServiceStartInit;
import io.swagger.annotations.ApiOperation;
import okhttp3.ConnectionPool;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@@ -45,6 +49,7 @@
import javax.annotation.Resource;
import java.nio.charset.Charset;
import java.util.concurrent.TimeUnit;
/**
@@ -118,6 +123,20 @@
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)).build();
    }
    @Bean
    @ConditionalOnBean(Java110FeignClientAop.class)
    public okhttp3.OkHttpClient okHttpClient(@Autowired
                                                     Java110FeignClientAop okHttpLoggingInterceptor){
        okhttp3.OkHttpClient.Builder ClientBuilder = new okhttp3.OkHttpClient.Builder()
                .readTimeout(30, TimeUnit.SECONDS) //读取超时
                .connectTimeout(10, TimeUnit.SECONDS) //连接超时
                .writeTimeout(60, TimeUnit.SECONDS) //写入超时
                .connectionPool(new ConnectionPool(10 /*maxIdleConnections*/, 3, TimeUnit.MINUTES))
                .addInterceptor(okHttpLoggingInterceptor);
        return ClientBuilder.build();
    }
    /**
     * 创建该API的基本信息(这些基本信息会展现在文档页面中)
     * 访问地址:http://项目实际地址/swagger-ui.html
service-api/src/main/resources/application-zihao.yml
@@ -66,6 +66,10 @@
      default:
        connect-timeout: 10000
        read-timeout: 20000
  httpclient:
    enabled: false
  okhttp:
    enabled: true
#============== kafka ===================