gs-rest-service icon indicating copy to clipboard operation
gs-rest-service copied to clipboard

Rest Service guide is missing source code for RestServiceApplication.java

Open cybersteel8 opened this issue 5 years ago • 4 comments

https://spring.io/guides/gs/rest-service/

This page contains the source code to build this application from scratch, however at the section where @SpringBootApplication is mentioned, there is no associated source code. I had to come here to find it.

cybersteel8 avatar Jan 24 '20 00:01 cybersteel8

do you want to see code below in documentation?

package com.example.restservice;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class RestServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(RestServiceApplication.class, args);
    }

}


boraoren avatar Jul 23 '20 01:07 boraoren

I was also confused about the @SpringBootApplication part of the guide as well what to do with the DemoApplication.java that came included with the Spring Initializr download. I think adding the following steps to the official guide on the site would be helpful for beginners:

  1. Create a new file called src/main/java/com/example/restservice/RestServiceApplication.java
  2. Add code mentioned by @boraoren above.
  3. Delete src/main/java/com/example/demo/DemoApplication.java

tas09009 avatar Oct 23 '20 16:10 tas09009

Yea this can easily be confusing for people that are just getting into Spring.

TimFurdui avatar Mar 16 '21 18:03 TimFurdui

Yeah, all 3 classes (DemoApplication, Greeting and GreetingController) should be in the same package (either com/example/demo or com/example/restservice, like the tutorial says) or else localhost:8080/greeting returns an error page.

MoskovchenkoD avatar Jan 27 '22 21:01 MoskovchenkoD

PR https://github.com/spring-guides/gs-rest-service/pull/125 fixes it, but I have requested a change to it.

In the meantime, you can find that class in /complete/src/main/java/com/example/consumingrest/ConsumingRestApplication.java

Buzzardo avatar Oct 09 '23 18:10 Buzzardo