Commit be32eecbafaa9925acf8febca78aca7a808d0319

Authored by changpengfei
1 parent 7d00f1ea59
Exists in master and in 1 other branch dev

启动命令配置修改

Showing 7 changed files with 47 additions and 4 deletions

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
... ... @@ -43,8 +43,8 @@
43 43 @Value("${hx.app_name}")
44 44 private String appName;
45 45  
46   -
47   - private RestTemplate restTemplate=new RestTemplate();
  46 + @Autowired
  47 + private RestTemplate restTemplate;
48 48 private ResponseEntity<String> resp;
49 49  
50 50 // @Autowired
talkonlineweb/src/main/resources/application-dev.yml View file @ be32eec
... ... @@ -21,4 +21,7 @@
21 21  
22 22 #微信支付通知地址
23 23 notify.url: https://dev-talk-api.healthbaby.com.cn/order/payNotify
  24 +
  25 +proxyIP:
  26 +proxyPort:
talkonlineweb/src/main/resources/application-prod.yml View file @ be32eec
... ... @@ -20,4 +20,7 @@
20 20  
21 21 #微信支付通知地址
22 22 notify.url: https://talk-api.healthbaby.com.cn/order/payNotify
  23 +
  24 +proxyIP:
  25 +proxyPort:
talkonlineweb/src/main/resources/restart.sh View file @ be32eec
  1 +#!/bin/bash
  2 +ps -ef | grep talkonline| grep -v grep | awk '{print $2}' | xargs kill -9 >/dev/null 2>&1 &
  3 +echo stop
  4 +sleep 1
  5 +nohup java -cp .:./lib/* -Djava.net.preferIPv4Stack=true com.lyms.talkonlineweb.TalkonlinewebApplication &
  6 +echo startUp finished!
talkonlineweb/src/main/resources/startUp.sh View file @ be32eec
  1 +#!/bin/bash
  2 +nohup java -cp .:./lib/* -Djava.net.preferIPv4Stack=true com.lyms.talkonlineweb.TalkonlinewebApplication &
  3 +echo startUp finished!
talkonlineweb/src/main/resources/stop.sh View file @ be32eec
  1 +#!/bin/bash
  2 +ps -ef | grep talkonline| grep -v grep | awk '{print $2}' | xargs kill -9 >/dev/null 2>&1 &
  3 +echo stop