spring-guides / gs-consuming-rest

Consuming a RESTful Web Service :: Learn how to retrieve web page data with Spring's RestTemplate.
https://spring.io/guides/gs/consuming-rest/
Apache License 2.0
195 stars 287 forks source link

Source code for Application.java (Standalone Version) does not compile #26

Closed Jens-OC closed 7 years ago

Jens-OC commented 7 years ago

The example source code for the first version of the src/main/java/hello/Application.java (standalone version) does not contain the package declaration is is missing the imports as well. For that reason it does not compile directly.

Though fixing the file is not a big issue it might confuse java newbies and I suggest to replace the existing example source code with the following one that compiles without errors:

package hello;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.client.RestTemplate;

public class Application {

    private static final Logger log = LoggerFactory.getLogger(Application.class);

    public static void main(String args[]) {
        RestTemplate restTemplate = new RestTemplate();
        Quote quote = restTemplate.getForObject("http://gturnquist-quoters.cfapps.io/api/random", Quote.class);
        log.info(quote.toString());
    }
}
gregturn commented 7 years ago

Afraid I don't understand this issue.

https://github.com/spring-guides/gs-consuming-rest/blob/master/complete/src/main/java/hello/Application.java shows exactly what you're talking about.

gregturn commented 7 years ago

Executing test/run.sh against the whole repository, and everything passes.

Jens-OC commented 7 years ago

I'm talking about the sources presented on the website, not the ones that are packaged in the download section:

grafik

Unlike the other source listings in this guide this one does not include the package declaration and imports. If the reader of the guide chooses to copy / paste the file contents instead of downloading the package this might result in issues. Sorry for missing to state this in the initial description.