我已经创建了演示Spring Boot项目并实现了Restful服务,如下所示
@RestController
public class GreetingsController {
@RequestMapping(value="/api/greetings", method=RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> getGreetings(){
return new ResponseEntity<String>("Hello World", HttpStatus.OK);
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试使用Postman工具调用带有URL" http:// localhost:8080/api/greetings "作为请求方法GET的服务时,我收到以下错误消息
{
"timestamp": 1449495844177,
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/api/greetings"
}
Run Code Online (Sandbox Code Playgroud)
Per Spring Boot应用程序,我不必在web.xml中配置Spring Dispatcher servlet.
有人可以帮我找出这里遗漏的地方吗?