Update spring.io metadata strategy to use the new API

Prior to this commit, the Spring Boot metadata reader would use a legacy
API endpoint on spring.io to fetch the Spring Boot versions.
The current website is about to be retired for a different
infrastructure and we should take this opportunity to update the
endpoint we're using.

This commit updates the metadata reader strategy to now use the
`https://spring.io/api/projects/spring-boot/releases` endpoint to fetch
the relevant information. The JSON format itself changed slightly and
this commit adapts to the new format as well.

Closes gh-1369
This commit is contained in:
Brian Clozel
2023-01-18 15:02:42 +01:00
parent d9fb4b05b4
commit c1e222901d
15 changed files with 341 additions and 316 deletions

View File

@@ -46,12 +46,12 @@ Finally, you can configure your IDE to point to another service instance.
There are two main customizations to the sample.
=== Metadata Update Strategy
First, `ServiceApplication` has a dedicated strategy to update the metadata with the available Spring Boot versions from Sagan (`spring.io`).
First, `ServiceApplication` has a dedicated strategy to update the metadata with the available Spring Boot versions from `https://spring.io`.
When you issue your first request, you should see something like the following:
[indent=0]
----
Fetching Spring Boot metadata from https://spring.io/project_metadata/spring-boot
Fetching Spring Boot metadata from https://spring.io/api/projects/spring-boot/releases
----
On further request, you won't see this log entry as the content is cached.

View File

@@ -17,7 +17,7 @@
package sample.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.spring.initializr.web.support.SaganInitializrMetadataUpdateStrategy;
import io.spring.initializr.web.support.SpringIoInitializrMetadataUpdateStrategy;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -40,11 +40,11 @@ public class ServiceApplication {
SpringApplication.run(ServiceApplication.class, args);
}
// This bean opt-in for fetching available Spring Boot versions from Sagan (spring.io)
// This bean opt-in for fetching available Spring Boot versions from https://spring.io
@Bean
SaganInitializrMetadataUpdateStrategy saganInitializrMetadataUpdateStrategy(RestTemplateBuilder restTemplateBuilder,
ObjectMapper objectMapper) {
return new SaganInitializrMetadataUpdateStrategy(restTemplateBuilder.build(), objectMapper);
SpringIoInitializrMetadataUpdateStrategy springIoInitializrMetadataUpdateStrategy(
RestTemplateBuilder restTemplateBuilder, ObjectMapper objectMapper) {
return new SpringIoInitializrMetadataUpdateStrategy(restTemplateBuilder.build(), objectMapper);
}
}