yo lo puse asi:
package com.aluracursos.screenmatch;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import java.io.IOException; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse;
@SpringBootApplication public class ScreenmatchApplication implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(ScreenmatchApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
System.out.println("Hola Mundo desde Spring");
public String obtenerDatos(String String url = "";
url) {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.build();
HttpResponse<String> response = null;
try {
response = client
.send(request, HttpResponse.BodyHandlers.ofString());
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
String json = response.body();
return json;
}
}
} y no se si eso estara bien