From dc3c689dee0aaab64e9e67997b8ebc29b6197003 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Sun, 8 Dec 2024 06:48:48 +0000 Subject: [PATCH] fix : starting problem --- .../learning/mfscreener/config/Initializer.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/learning/mfscreener/config/Initializer.java b/src/main/java/com/learning/mfscreener/config/Initializer.java index 0ab6e34c..a0916454 100644 --- a/src/main/java/com/learning/mfscreener/config/Initializer.java +++ b/src/main/java/com/learning/mfscreener/config/Initializer.java @@ -10,6 +10,7 @@ import java.io.IOException; import java.io.Reader; import java.io.StringReader; +import java.net.URI; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -21,7 +22,7 @@ import org.springframework.util.StringUtils; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.ResourceAccessException; -import org.springframework.web.client.RestTemplate; +import org.springframework.web.client.RestClient; @Component public class Initializer implements CommandLineRunner { @@ -30,17 +31,17 @@ public class Initializer implements CommandLineRunner { private final SchemeService schemeService; private final MfSchemeDtoToEntityMapper mfSchemeDtoToEntityMapper; - private final RestTemplate restTemplate; + private final RestClient restClient; private final MFSchemeNavService mfSchemeNavService; public Initializer( SchemeService schemeService, MfSchemeDtoToEntityMapper mfSchemeDtoToEntityMapper, - RestTemplate restTemplate, + RestClient restClient, MFSchemeNavService mfSchemeNavService) { this.schemeService = schemeService; this.mfSchemeDtoToEntityMapper = mfSchemeDtoToEntityMapper; - this.restTemplate = restTemplate; + this.restClient = restClient; this.mfSchemeNavService = mfSchemeNavService; } @@ -49,7 +50,11 @@ public void run(String... args) throws IOException { long start = System.currentTimeMillis(); LOGGER.info("Loading All Funds..."); try { - String allNAVs = restTemplate.getForObject(AppConstants.AMFI_WEBSITE_LINK, String.class); + String allNAVs = restClient + .get() + .uri(URI.create(AppConstants.AMFI_WEBSITE_LINK)) + .retrieve() + .body(String.class); Reader inputString = new StringReader(Objects.requireNonNull(allNAVs)); List chopArrayList = new ArrayList<>(); try (BufferedReader br = new BufferedReader(inputString)) {