1.确认访问地址是否正确
(1)确认端口号是否正确,默认是8080,这个可以在启动的控制台进行查看;
(2)确认访问URI是否填写正确,这个可以在启动的控制台查看是否被映射;
2.确认注解是否正确,使用@RestController注解,而不是@Controller,
另外@RestController注解,等价于@Controller和@ResponseBody注解;
3.确定包的路径是否正确
我们需要知道的是:Spring Boot默认情况下,扫描到的是
@SpringBootApplication所在的类的同包,或子包下的类;
4.确定类引入的包的路径是否正确
@RestController引入的包是:import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/xxs")引入的包是:import org.springframework.web.bind.annotation.RequestMapping;