diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/config/MyWebConfig.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/config/MyWebConfig.java index 2f61c07..d933ed2 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/config/MyWebConfig.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/config/MyWebConfig.java @@ -1,17 +1,31 @@ package com.lyms.talkonlineweb.config; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.util.StringUtils; +import org.springframework.web.client.RestTemplate; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.SocketAddress; + @Configuration public class MyWebConfig implements WebMvcConfigurer { @Value("${excludePath}") private String excludePath; + @Value("${proxyIP}") + private String proxyIP; + + @Value("${proxyPort}") + private String proxyPort; + @Override public void addInterceptors(InterceptorRegistry registry) { // WebMvcConfigurer.super.addInterceptors(registry); @@ -27,4 +41,15 @@ public class MyWebConfig implements WebMvcConfigurer { // .allowedMethods("GET", "POST", "DELETE", "PUT","OPTIONS") // .maxAge(3600); } + + @Bean + public RestTemplate restTemplate(){ + SimpleClientHttpRequestFactory httpRequestFactory=new SimpleClientHttpRequestFactory(); + if(!StringUtils.isEmpty(proxyIP)){ + SocketAddress address=new InetSocketAddress(proxyIP,Integer.parseInt(proxyPort)); + Proxy proxy=new Proxy(Proxy.Type.HTTP,address); + httpRequestFactory.setProxy(proxy); + } + return new RestTemplate(httpRequestFactory); + } } diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/HXService.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/HXService.java index 480ba52..c9b66b0 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/HXService.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/HXService.java @@ -43,8 +43,8 @@ public class HXService { @Value("${hx.app_name}") private String appName; - - private RestTemplate restTemplate=new RestTemplate(); + @Autowired + private RestTemplate restTemplate; private ResponseEntity resp; // @Autowired diff --git a/talkonlineweb/src/main/resources/application-dev.yml b/talkonlineweb/src/main/resources/application-dev.yml index 8de7352..0de462e 100644 --- a/talkonlineweb/src/main/resources/application-dev.yml +++ b/talkonlineweb/src/main/resources/application-dev.yml @@ -20,4 +20,7 @@ hx.hxuser: test hx.hxpasswd: passwd #微信支付通知地址 -notify.url: https://dev-talk-api.healthbaby.com.cn/order/payNotify \ No newline at end of file +notify.url: https://dev-talk-api.healthbaby.com.cn/order/payNotify + +proxyIP: +proxyPort: \ No newline at end of file diff --git a/talkonlineweb/src/main/resources/application-prod.yml b/talkonlineweb/src/main/resources/application-prod.yml index 88fb765..94c8871 100644 --- a/talkonlineweb/src/main/resources/application-prod.yml +++ b/talkonlineweb/src/main/resources/application-prod.yml @@ -19,4 +19,7 @@ hx.hxuser: test hx.hxpasswd: passwd #微信支付通知地址 -notify.url: https://talk-api.healthbaby.com.cn/order/payNotify \ No newline at end of file +notify.url: https://talk-api.healthbaby.com.cn/order/payNotify + +proxyIP: +proxyPort: \ No newline at end of file diff --git a/talkonlineweb/src/main/resources/restart.sh b/talkonlineweb/src/main/resources/restart.sh new file mode 100644 index 0000000..3bc8f87 --- /dev/null +++ b/talkonlineweb/src/main/resources/restart.sh @@ -0,0 +1,6 @@ +#!/bin/bash +ps -ef | grep talkonline| grep -v grep | awk '{print $2}' | xargs kill -9 >/dev/null 2>&1 & +echo stop +sleep 1 +nohup java -cp .:./lib/* -Djava.net.preferIPv4Stack=true com.lyms.talkonlineweb.TalkonlinewebApplication & +echo startUp finished! \ No newline at end of file diff --git a/talkonlineweb/src/main/resources/startUp.sh b/talkonlineweb/src/main/resources/startUp.sh new file mode 100644 index 0000000..f83a43d --- /dev/null +++ b/talkonlineweb/src/main/resources/startUp.sh @@ -0,0 +1,3 @@ +#!/bin/bash +nohup java -cp .:./lib/* -Djava.net.preferIPv4Stack=true com.lyms.talkonlineweb.TalkonlinewebApplication & +echo startUp finished! diff --git a/talkonlineweb/src/main/resources/stop.sh b/talkonlineweb/src/main/resources/stop.sh new file mode 100644 index 0000000..88782f3 --- /dev/null +++ b/talkonlineweb/src/main/resources/stop.sh @@ -0,0 +1,3 @@ +#!/bin/bash +ps -ef | grep talkonline| grep -v grep | awk '{print $2}' | xargs kill -9 >/dev/null 2>&1 & +echo stop