SpringBoot集成Spring & SpringMVC
1、@ComponentScan注解
2、默认扫描默认扫描当前包com.atguigu.crowdfunding和子包com.atguigu.crowdfunding.*如果还需要扫描其他的包,那么需要增加@ComponentSc锾攒揉敫an注解,指定包名进行扫描。
3、增加控制器代码在src/main/java目录中增加类com.atguigu.crowdfunding.controller.MemberController,并增加相应代码。
4、执行main方法启动应用l 访问路径http://127.0.0.1:8080[/应用路径名称]/member/index 页面打印JSON字符串即可
5、@Controller和@Rest觊皱筠桡Controller区别官方文档:@RestController is a stereotype an荏鱿胫协notation that combines @ResponseBody and @Controller.表示@RestController等同于@Controller + @ResponseBody,所以上面的代码可以变为:
6、增加服务层代码Service接口,ServiceImpl实现类的使用和SSM架构中的使用方式完全相同。
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。