he2802 4 سال پیش
والد
کامیت
334536c087

+ 9 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/ZhongZhengApplication.java

@@ -3,6 +3,9 @@ package com.zhongzheng;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.context.annotation.Bean;
+import org.springframework.web.client.RestTemplate;
 
 /**
  * 启动程序
@@ -19,4 +22,10 @@ public class ZhongZhengApplication
         SpringApplication.run(ZhongZhengApplication.class, args);
         System.out.println("(♥◠‿◠)ノ゙  中正启动成功   ლ(´ڡ`ლ)゙");
     }
+
+    @Bean
+    @LoadBalanced
+    RestTemplate restTemplate(){
+        return new RestTemplate();
+    }
 }

+ 4 - 0
zhongzheng-admin/src/main/resources/application.yml

@@ -240,3 +240,7 @@ feign:
     enabled: true
   hystrix:
     enabled: true
+wx:
+  small:
+    appid: 123
+    appsecret: 3434

+ 9 - 0
zhongzheng-api/src/main/java/com/zhongzheng/ZhongZhengApiApplication.java

@@ -4,7 +4,10 @@ package com.zhongzheng;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
+import org.springframework.web.client.RestTemplate;
 
 
 @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@@ -16,4 +19,10 @@ public class ZhongZhengApiApplication {
         SpringApplication.run(ZhongZhengApiApplication.class, args);
         System.out.println("(♥◠‿◠)ノ゙  中正API启动成功   ლ(´ڡ`ლ)゙");
     }
+
+    @Bean
+    @LoadBalanced
+    RestTemplate restTemplate(){
+        return new RestTemplate();
+    }
 }