不同type,项目结构不一样,默认选择Maven Project。使用@RestController注解:添加引用:import org.springframework.web.bind.annotation.RestController; 或者开启自动添加引用。没有数据库配置不要勾选mybatis。添加Controller文件。注意:controller的代码必须和DemoApplication.Java位于同级目录或之下:完成,点击运行: