yuedy

http://localhpost:8080/hello

 

 代码结构:

 

 

代码内容:

 1 @RestController
 2 public class HelloWordRestImpl implements HelloWordRest{
 3 
 4     @Autowired
 5     public HelloWordService helloWordService;
 6 
 7     @Override
 8     @RequestMapping("/say")
 9     public String say() {
10         return helloWordService.say();
11     }
12 
13     @Override
14     @RequestMapping("/hello")
15     public String hello() {
16         return "hello";
17     }
18 }

解决方案:

1、首先查看自己配的controller路径是否和访问路径一致;
2、在确保springboot服务正常启动的情况,打开本地host,查看localhost的ip是否使用,一般情况是127.0.0.1,如果是注释的就放开;
3、如果你的springboot启动类和springbootController包是在不同的包里,就需要添加
@ComponentScan(basePackages = {"xx.xxx.*"}),后面是你的包路径  
      这样就能扫面到controller包;从而访问成功;

分类:

技术点:

相关文章:

  • 2021-10-21
  • 2021-04-24
  • 2021-08-31
  • 2022-12-23
  • 2021-09-28
  • 2022-01-22
  • 2021-05-29
猜你喜欢
  • 2021-07-17
  • 2021-10-08
  • 2021-10-01
  • 2021-10-10
  • 2021-08-01
相关资源
相似解决方案