Perform various data analysis on SEC 13-F and obtain some insights of fund activities such as number of holdings, AUM, and change of holdings between two quarters.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Migrate RestTemplate to RestClient in Spring Boot 3.2+. Use when replacing deprecated RestTemplate with modern fluent API, updating HTTP client code, or configuring RestClient beans. Covers GET/POST/DELETE migrations, error handling, and ParameterizedTypeReference usage.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
설치 방법 보기설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.
Spring Framework 6.1 (Spring Boot 3.2+) introduces RestClient, a modern, fluent API for synchronous HTTP requests that replaces the older RestTemplate. While RestTemplate still works, RestClient is the recommended approach for new code.
| Feature | RestTemplate | RestClient |
|---|---|---|
| API Style | Template methods | Fluent builder |
| Configuration | Constructor injection | Builder pattern |
| Error handling | ResponseErrorHandler | Status handlers |
| Type safety | Limited | Better with generics |
@Service
public class ExternalApiService {
private final RestTemplate restTemplate;
public ExternalApiService() {
this.restTemplate = new RestTemplate();
}
public Map<String, Object> getUser(String userId) {
String url = "https://api.example.com/users/" + userId;
ResponseEntity<Map> response = restTemplate.getForEntity(url, Map.class);
return response.getBody();
}
}
@Service
public class ExternalApiService {
private final RestClient restClient;
public ExternalApiService() {
this.restClient = RestClient.create();
}
public Map<String, Object> getUser(String userId) {
return restClient.get()
.uri("https://api.example.com/users/{id}", userId)
.retrieve()
.body(new ParameterizedTypeReference<Map<String, Object>>() {});
}
}
public void sendNotification(String userId, String message) {
String url = baseUrl + "/notifications";
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
Map<String, String> payload = Map.of(
"userId", userId,
"message", message
);
HttpEntity<Map<String, String>> request = new HttpEntity<>(payload, headers);
restTemplate.postForEntity(url, request, Void.class);
}
public void sendNotification(String userId, String message) {
Map<String, String> payload = Map.of(
"userId", userId,
"message", message
);
restClient.post()
.uri(baseUrl + "/notifications")
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
.body(payload)
.retrieve()
.toBodilessEntity();
}
public Map<String, Object> enrichUserProfile(String userId) {
String url = baseUrl + "/users/" + userId + "/profile";
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
HttpEntity<?> request = new HttpEntity<>(headers);
ResponseEntity<Map> response = restTemplate.exchange(
url,
HttpMethod.GET,
request,
Map.class
);
return response.getBody();
}
public Map<String, Object> enrichUserProfile(String userId) {
return restClient.get()
.uri(baseUrl + "/users/{id}/profile", userId)
.accept(MediaType.APPLICATION_JSON)
.retrieve()
.body(new ParameterizedTypeReference<Map<String, Object>>() {});
}
public boolean requestDataDeletion(String userId) {
try {
String url = baseUrl + "/users/" + userId + "/data";
restTemplate.delete(url);
return true;
} catch (Exception e) {
return false;
}
}
public boolean requestDataDeletion(String userId) {
try {
restClient.delete()
.uri(baseUrl + "/users/{id}/data", userId)
.retrieve()
.toBodilessEntity();
return true;
} catch (Exception e) {
return false;
}
}
@Configuration
public class RestClientConfig {
@Value("${external.api.base-url}")
private String baseUrl;
@Bean
public RestClient restClient() {
return RestClient.builder()
.baseUrl(baseUrl)
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
.build();
}
}
@Service
public class ExternalApiService {
private final RestClient restClient;
public ExternalApiService(RestClient restClient) {
this.restClient = restClient;
}
// Methods can now use relative URIs
public Map<String, Object> getUser(String userId) {
return restClient.get()
.uri("/users/{id}", userId)
.retrieve()
.body(new ParameterizedTypeReference<Map<String, Object>>() {});
}
}
public Map<String, Object> getUserWithErrorHandling(String userId) {
return restClient.get()
.uri("/users/{id}", userId)
.retrieve()
.onStatus(HttpStatusCode::is4xxClientError, (request, response) -> {
throw new UserNotFoundException("User not found: " + userId);
})
.onStatus(HttpStatusCode::is5xxServerError, (request, response) -> {
throw new ExternalServiceException("External service error");
})
.body(new ParameterizedTypeReference<Map<String, Object>>() {});
}
// For generic types like Map or List
Map<String, Object> map = restClient.get()
.uri("/data")
.retrieve()
.body(new ParameterizedTypeReference<Map<String, Object>>() {});
List<User> users = restClient.get()
.uri("/users")
.retrieve()
.body(new ParameterizedTypeReference<List<User>>() {});
// For simple types
User user = restClient.get()
.uri("/users/{id}", userId)
.retrieve()
.body(User.class);
String text = restClient.get()
.uri("/text")
.retrieve()
.body(String.class);
@Service
public class ExternalApiService {
private final RestTemplate restTemplate;
@Value("${external.api.base-url}")
private String baseUrl;
public ExternalApiService() {
this.restTemplate = new RestTemplate();
}
public boolean verifyEmail(String email) {
try {
String url = baseUrl + "/verify/email?email=" + email;
ResponseEntity<Map> response = restTemplate.getForEntity(url, Map.class);
return Boolean.TRUE.equals(response.getBody().get("valid"));
} catch (Exception e) {
return false;
}
}
}
@Service
public class ExternalApiService {
private final RestClient restClient;
@Value("${external.api.base-url}")
private String baseUrl;
public ExternalApiService() {
this.restClient = RestClient.create();
}
public boolean verifyEmail(String email) {
try {
Map<String, Object> response = restClient.get()
.uri(baseUrl + "/verify/email?email={email}", email)
.retrieve()
.body(new ParameterizedTypeReference<Map<String, Object>>() {});
return response != null && Boolean.TRUE.equals(response.get("valid"));
} catch (Exception e) {
return false;
}
}
}
For reactive applications, use WebClient instead:
// WebClient for reactive/async operations
WebClient webClient = WebClient.create(baseUrl);
Mono<User> userMono = webClient.get()
.uri("/users/{id}", userId)
.retrieve()
.bodyToMono(User.class);
RestClient is preferred for synchronous operations in non-reactive applications.
아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.
로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.
아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.
Perform various data analysis on SEC 13-F and obtain some insights of fund activities such as number of holdings, AUM, and change of holdings between two quarters.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
AC branch pi-model power flow equations (P/Q and |S|) with transformer tap ratio and phase shift, matching `acopf-math-model.md` and MATPOWER branch fields. Use when computing branch flows in either direction, aggregating bus injections for nodal balance, checking MVA (rateA) limits, computing branch loading %, or debugging sign/units issues in AC power flow.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Redact text from PDF documents for blind review anonymization
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Use when checking simplified ADA-derived plan-view bathroom accessibility constraints such as turning space, door clear width, toilet centerline, grab bars, and lavatory knee/toe clearance.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Analyze failed GitHub Action jobs for a pull request.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Use when extracting plan-view architectural geometry from DXF files with semantic CAD layers, especially when outputs must normalize rooms, doors, fixtures, clearances, and grab bars into machine-checkable JSON.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.