gs-rest-service
gs-rest-service copied to clipboard
Rest Service guide is missing source code for RestServiceApplication.java
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.
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);
}
}
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:
- Create a new file called
src/main/java/com/example/restservice/RestServiceApplication.java
- Add code mentioned by @boraoren above.
- Delete
src/main/java/com/example/demo/DemoApplication.java
Yea this can easily be confusing for people that are just getting into Spring.
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.
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