我想运行一个应用程序,所以我可以在本地进行测试,但目前出现问题。在Spring Boot中运行localhost时出错
我使用gradle这个和下面这个教程
https://spring.io/guides/gs/serving-web-content/
不过,我完成了教程,并运行此命令:
./gradlew bootRun
应用程序启动,但我不能打到最后点。
它引发以下错误:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Fri Dec 16 16:25:06 GMT 2016
There was an unexpected error (type=Not Found, status=404).
No message available
任何想法如何解决这一问题?
package conf;
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);
}
}
问候语类
package controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
*/
@Controller
public class GreetingController {
@RequestMapping("/greeting")
public String greeting(@RequestParam(value="name", required=false, defaultValue="World") String name, Model model) {
model.addAttribute("name", name);
return "greeting";
}
}
感谢
你曾经通过完整的示例代码检查你的代码 “GS-服务 - 网络内容/完成” 文件夹中的[ zip文件](https://github.com/spring-guides/gs-serving-web-content.git)? – Alic
我从头开始,所以我没有检查zip文件中的代码。 – Sgr
通过检查已完成的示例,您将能够看到您做错了什么。 – Alic