質問: ホワイトラベルのエラー ページが表示されるのはなぜですか?
正確なエラー:
ホワイトラベル エラー ページ
このアプリケーションには /error の明示的なマッピングがないため、これはフォールバックとして表示されます。
Thu Sep 17 12:11:02 CDT 2015
There was an unexpected error (type=Not Found, status=404).
No message available
背景: spring.io の入門ガイドに従って、Spring を使用して RESTful Web サービスを構築しています。
https://spring.io/guides/gs/rest-service/#scratch
私はSpringツールスイートを使用しており、チュートリアルに従ってキーを設定しました。
私のコード:
あいさつ.java
package hello;
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;
}
}
GreetingController.java
package hello;
import java.util.concurrent.atomic.AtomicLong;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestParam;
@RestController
public class GreetingController {
private final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();
@RequestMapping("/greeter")
public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) {
return new Greeting( counter.incrementAndGet(), String.format(template, name));
}
}
アプリケーション.java
package hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}