老师,这是怎么回事,路径是对的,启动类也在控制器类外面啊

来源:2-3 使用Maven构建Spring Boot项目

射手流星jia

2020-08-14 23:00:58

package com.imooc.myspringboot.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

public class MyController {
   @RequestMapping("/out")
   @ResponseBody
   public String out(){
       return "success";
   }


}


package com.imooc.myspringboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

//说明这是SpringBoot应用的入口类
@SpringBootApplication
public class MySpringBootApplication {
   public static void main(String[] args){
       //启动SpringBoot应用
       SpringApplication.run(MySpringBootApplication.class);
   }
}
http://img.mukewang.com/climg/5f36a61409adb05413660768.jpg

http://img.mukewang.com/climg/5f36a6290928ce2b13660768.jpg

写回答

1回答

好帮手慕小脸

2020-08-15

同学你好,在MyController类上需添加@Controller。如下所示:

http://img.mukewang.com/climg/5f3756b609d1a81603940089.jpg

如果我的回答解决了你的疑惑,请采纳,祝学习愉快~

0

0 学习 · 8263 问题

查看课程