| | |
| | | package com.sinata.zuul; |
| | | |
| | | import com.sinata.zuul.util.applets.NettyServer0; |
| | | import com.sinata.zuul.util.echo.NettyServer; |
| | | import com.spring4all.swagger.EnableSwagger2Doc; |
| | | import org.apache.http.client.HttpClient; |
| | | import org.apache.http.config.SocketConfig; |
| | |
| | | import org.springframework.http.converter.StringHttpMessageConverter; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.client.RestTemplate; |
| | | import org.springframework.web.cors.CorsConfiguration; |
| | | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; |
| | | import org.springframework.web.filter.CorsFilter; |
| | | import springfox.documentation.swagger.web.SwaggerResource; |
| | | import springfox.documentation.swagger.web.SwaggerResourcesProvider; |
| | | |
| | |
| | | |
| | | public static void main(String[] args) { |
| | | SpringApplication.run(ZuulApplication.class, args); |
| | | // NettyServer nettyServer = new NettyServer(); |
| | | // nettyServer.bind(); |
| | | // NettyServer0 nettyServer0 = new NettyServer0(); |
| | | // nettyServer0.bind(); |
| | | } |
| | | |
| | | |
| | |
| | | restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8)); |
| | | return restTemplate; |
| | | } |
| | | |
| | | |
| | | |
| | | // /** |
| | | // * 向Spring容器中定义RestTemplate对象 |
| | | // * @return |
| | | // */ |
| | | // @Bean //必须new 一个RestTemplate并放入spring容器当中,否则启动时报错 |
| | | // public RestTemplate restTemplate() { |
| | | // PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); |
| | | // connectionManager.setDefaultSocketConfig(SocketConfig.custom().setTcpNoDelay(true).build()); |
| | | // connectionManager.setDefaultMaxPerRoute(100);//最大并发连接 |
| | | // connectionManager.setMaxTotal(200); // 总的最大连接数 |
| | | // HttpClient httpClient = HttpClientBuilder.create().setConnectionManager(connectionManager).build(); |
| | | // HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory(httpClient); |
| | | // httpRequestFactory.setConnectionRequestTimeout(30 * 1000); |
| | | // httpRequestFactory.setConnectTimeout(30 * 3000); |
| | | // httpRequestFactory.setReadTimeout(30 * 3000); |
| | | // RestTemplate restTemplate = new RestTemplate(httpRequestFactory); |
| | | // restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8)); |
| | | // return restTemplate; |
| | | // } |
| | | |
| | | |
| | | |
| | | /** |