Explorar o código

开发计算机不获取token

lighter %!s(int64=4) %!d(string=hai) anos
pai
achega
a3af573726

+ 11 - 0
src/main/java/thyyxxk/webserver/scheduled/FetchAccessTokenTask.java

@@ -7,6 +7,8 @@ import org.springframework.stereotype.Component;
 import org.springframework.web.client.RestTemplate;
 import thyyxxk.webserver.utils.TokenUtil;
 
+import java.net.InetAddress;
+
 @Slf4j
 @Component
 public class FetchAccessTokenTask {
@@ -23,6 +25,15 @@ public class FetchAccessTokenTask {
 
     @Scheduled(fixedRate = 6900 * 1000)
     public void getAccessToken() {
+        try {
+            InetAddress addr = InetAddress.getLocalHost();
+            String address=addr.getHostName();
+            if ("THYYXXK-DJ".equals(address)) {
+                return;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
         RestTemplate restTemplate = new RestTemplate();
         String httpRes = restTemplate.getForObject(USERINFO_ACCESS_TOKEN_URL, String.class);
         JSONObject json = JSONObject.parseObject(httpRes);