SpringBoot集成Spring & SpringMVC
1、@ComponentScan注解

2、默认扫描
默认扫描当前包com.atguigu.crowdfunding和子包com.atguigu.crowdfunding.*
如果还需耍盯要扫描其他的包,那么需要增加@ComponentScan注解,指定包名进行扫罪戴描。
3、增加控制器代码
在src/main/java目录中增加类com.atguigu.crowdfunding.controller.MemberController,并增加相应代码。

4、执行main方法启动应用
l 访问路径http://127.0.0.1:8080[/应用路径名称]/member/index 页面打印JSON字符串即可

5、@Controller和@RestController区别
官方文档:@RestController is a stereotype annotation that combines @ResponseBody and @Controller.
表示@RestController等同于@Controller + @ResponseBody,所以上面的代码可以变为:惹处肤

6、增加服务层代码
Service接口,ServiceImpl实现类的使用和SSM架构中的使用方式完全相同。

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:155
阅读量:76
阅读量:101
阅读量:92
阅读量:123