From 8b3f7e86472dd2df07ee3ab310bd30f6bdcab942 Mon Sep 17 00:00:00 2001 From: yangmengchuan Date: Fri, 17 Jan 2025 14:07:55 +0800 Subject: [PATCH] =?UTF-8?q?restTemplate=20=20Bean=E6=B3=A8=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/keyware/htey/config/HertzServerConfig.java | 6 ++++++ .../com/keyware/htey/controller/hertz/HertzController.java | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/keyware/htey/config/HertzServerConfig.java b/src/main/java/com/keyware/htey/config/HertzServerConfig.java index 90aeecd..8e42448 100644 --- a/src/main/java/com/keyware/htey/config/HertzServerConfig.java +++ b/src/main/java/com/keyware/htey/config/HertzServerConfig.java @@ -3,7 +3,9 @@ package com.keyware.htey.config; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; /** * 监控三方服务配置 @@ -12,6 +14,10 @@ import org.springframework.context.annotation.Configuration; @Configuration @ConfigurationProperties(prefix = "hertz") public class HertzServerConfig { + @Bean + public RestTemplate restTemplate() { + return new RestTemplate(); + } /** * 服务地址 */ diff --git a/src/main/java/com/keyware/htey/controller/hertz/HertzController.java b/src/main/java/com/keyware/htey/controller/hertz/HertzController.java index 8e5113c..e591c13 100644 --- a/src/main/java/com/keyware/htey/controller/hertz/HertzController.java +++ b/src/main/java/com/keyware/htey/controller/hertz/HertzController.java @@ -30,8 +30,6 @@ public class HertzController { @ApiResponse(responseCode = "200", description = "系统监视") public Object selectAll() throws IOException { Map monitorData = hertzBeatClient.getMonitorData(); - // 将 JSON 字符串转换为 Map - System.out.println("1"); return monitorData; } }