工作休息教程扔了春季啓動網站,並收到404錯誤。該網站說,如果我使用RestController註釋,一個視圖(百里香葉)是不需要的,似乎我有這個404錯誤。讓我知道我做錯了什麼。春天和休息服務
主營:
@SpringBootApplication
@ComponentScan("com.ronone.entity")
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
控制器:
@RestController
public class Controller {
private static final String template = "Hello %s!";
private final AtomicLong counter = new AtomicLong();
@GetMapping("/greeting")
public Greeting greeting(@RequestParam(value = "name", defaultValue = "World")String name){
return new Greeting(counter.incrementAndGet(),
String.format(template, name));
}
}
平原OLE的java:
public class Greeting {
private final long id;
private final String content;
public Greeting(long id, String content) {
this.id = id;
this.content = content;
}
public long getId() {
return id;
}
public String getContent() {
return content;
}
}
更多關於
@ComponentScan
什麼網址給你'404'? –http:// localhost:8080/greeting –
啓動彈出式應用程序時,控制檯中是否有任何錯誤日誌?只是爲了確認應用程序已正確啓動。 –