Commit be32eecbafaa9925acf8febca78aca7a808d0319
1 parent
7d00f1ea59
Exists in
master
启动命令配置修改
Showing 7 changed files with 47 additions and 4 deletions
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/config/MyWebConfig.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/HXService.java
- talkonlineweb/src/main/resources/application-dev.yml
- talkonlineweb/src/main/resources/application-prod.yml
- talkonlineweb/src/main/resources/restart.sh
- talkonlineweb/src/main/resources/startUp.sh
- talkonlineweb/src/main/resources/stop.sh
talkonlineweb/src/main/java/com/lyms/talkonlineweb/config/MyWebConfig.java
View file @
be32eec
1 | 1 | package com.lyms.talkonlineweb.config; |
2 | 2 | |
3 | 3 | import org.springframework.beans.factory.annotation.Value; |
4 | +import org.springframework.context.annotation.Bean; | |
4 | 5 | import org.springframework.context.annotation.Configuration; |
6 | +import org.springframework.http.client.SimpleClientHttpRequestFactory; | |
7 | +import org.springframework.util.StringUtils; | |
8 | +import org.springframework.web.client.RestTemplate; | |
5 | 9 | import org.springframework.web.servlet.config.annotation.CorsRegistry; |
6 | 10 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
7 | 11 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
8 | 12 | |
13 | +import java.net.InetSocketAddress; | |
14 | +import java.net.Proxy; | |
15 | +import java.net.SocketAddress; | |
16 | + | |
9 | 17 | @Configuration |
10 | 18 | public class MyWebConfig implements WebMvcConfigurer { |
11 | 19 | |
12 | 20 | @Value("${excludePath}") |
13 | 21 | private String excludePath; |
14 | 22 | |
23 | + @Value("${proxyIP}") | |
24 | + private String proxyIP; | |
25 | + | |
26 | + @Value("${proxyPort}") | |
27 | + private String proxyPort; | |
28 | + | |
15 | 29 | @Override |
16 | 30 | public void addInterceptors(InterceptorRegistry registry) { |
17 | 31 | // WebMvcConfigurer.super.addInterceptors(registry); |
... | ... | @@ -26,6 +40,17 @@ |
26 | 40 | // .allowCredentials(true) |
27 | 41 | // .allowedMethods("GET", "POST", "DELETE", "PUT","OPTIONS") |
28 | 42 | // .maxAge(3600); |
43 | + } | |
44 | + | |
45 | + @Bean | |
46 | + public RestTemplate restTemplate(){ | |
47 | + SimpleClientHttpRequestFactory httpRequestFactory=new SimpleClientHttpRequestFactory(); | |
48 | + if(!StringUtils.isEmpty(proxyIP)){ | |
49 | + SocketAddress address=new InetSocketAddress(proxyIP,Integer.parseInt(proxyPort)); | |
50 | + Proxy proxy=new Proxy(Proxy.Type.HTTP,address); | |
51 | + httpRequestFactory.setProxy(proxy); | |
52 | + } | |
53 | + return new RestTemplate(httpRequestFactory); | |
29 | 54 | } |
30 | 55 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/HXService.java
View file @
be32eec
talkonlineweb/src/main/resources/application-dev.yml
View file @
be32eec
talkonlineweb/src/main/resources/application-prod.yml
View file @
be32eec
talkonlineweb/src/main/resources/restart.sh
View file @
be32eec
talkonlineweb/src/main/resources/startUp.sh
View file @
be32eec
talkonlineweb/src/main/resources/stop.sh
View file @
be32eec