RestTemplate configuration and usage

In the project, if you want to call a third-party http service, you need to initiate an http request. Common request methods: The first one is to use java natively to initiate an http request. This method does not require the introduction of a third-party library, but the connection cannot be reused. , if you […]

Transitioning from RestTemplate to WebClient in SpringBoot (detailed guide)

Original link: https://medium.com/hprog99/transitioning-from-resttemplate-to-webclient-in-spring-boot-a-detailed-guide-4febd21063ba Author: Hiten Pratap Singh The Spring Framework’s RestTemplate has been the go-to solution for client-side HTTP access for years, providing a synchronous, blocking API to handle HTTP requests in a simple way. However, as the need for non-blocking, reactive programming to handle concurrency with fewer resources increases, especially in microservices architectures, RestTemplate […]

Transitioning from RestTemplate to WebClient in SpringBoot: A Detailed Guide

The path to growth as a programmer Internet/Programmer/Technology/Data Sharing focus on This article should take approximately 8 minutes to read. From: https://medium.com/hprog99 The Spring Framework’s RestTemplate has been the go-to solution for client-side HTTP access for years, providing a synchronous, blocking API to handle HTTP requests in a simple way. However, as the need for […]

RestTemplate directly sends memory file object multipart

1. RestTemplate directly sends the memory file object multipart 1. Create a byte array output stream object and use the write method of the Word document object to write its content to the stream 2. Use Spring’s RestTemplate to send POST requests containing attachments. Use HttpHeaders to set multipart/form-data headers: Then, a resource object consisting […]

12.Usage of SpringBoot’s RestTemplate

Usage of SpringBoot’s RestTemplate First introduction to RestTemplate RestTemplate is an application provided by the Spring framework for calling the Rest interface, which simplifies communication with http services. RestTemplate unifies the standard for Restfull calls and encapsulates HTTP links. As long as the URL and return value type are required, the call can be completed. […]

Ribbon load balancing + RestTemplate call

1. Introduction to Ribbon load balancing Ribbon is a component of Sping Cloud. Spring Cloud Ribbon is a load balancing solution. Ribbon is a load balancer released by Netflix. Spring has integrated it. Spring Cloud Ribbon is implemented based on Netflix Ribbon and is a tool for HTTP requests are controlled by the load balancing […]

RestTemplate sends HTTPS request

RestTemplate sends HTTPS request Basic knowledge: Https principle, workflow and certificate verification: https://www.cnblogs.com/zjdxr-up/p/14359904.html Configure how to ignore ssl certificate: import lombok.extern.slf4j.Slf4j; import org.springframework.http.client.SimpleClientHttpRequestFactory; import java.io.IOException; import java.net.HttpURLConnection; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.security.cert.X509Certificate; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; @Slf4j public class IgnoreCertificateHttpsClientRequestFactory extends SimpleClientHttpRequestFactory {<!– –> @Override protected void prepareConnection(HttpURLConnection […]

RestTemplate developed by Spring Boot skips the certificate to access https

In the Spring Boot project, RestTemplate is used directly to send requests to access the https address. If the JDK does not import the certificate, an unable to find valid certification path to requested target error will appear. . This chapter explains how to bypass the certificate to access https addresses. 2022-04-30 00:22:33.370 ERROR 808 […]

Skip ssl certificate verification when calling https request using RestTemplate

1. Required jar package (cv is enough) <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>5.0.7.RELEASE</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.58</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.9.5</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.9.5</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.9.5</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.module</groupId> <artifactId>jackson-module-jaxb-annotations</artifactId> <version>2.9.5</version> </dependency> 2. Enumeration class (only used as demo) import java.text.SimpleDateFormat; import java.util.Date; import java.util.UUID; /** * @ClassName TestEnum * […]

RestTemplate bypasses SSL certificate verification

In the previous article, we have completed the backend client’s access to the server interface in https mode by configuring RestTemplate. This article serves as a supplementary explanation to introduce how to bypass SSL certificate verification without a certificate. The configuration steps are as follows: 1. Delete the original certificate from the JDK certificate management […]