https://blog.csdn.net/u013777094/article/details/78580710/
使用springboot必须要java8或以上。
创建springboot项目的maven类型,必须是jar类型。
一、springboot的依赖继承
这里的spring-boot-starter-parent是干什么的呢?
其实,这里就是maven的父子工程的一个概念。在parent工程中放很多公用的依赖,子工程就可以通过maven依赖继承关系,来使用parent中的依赖。
从maven依赖可以看出,springboot集成了springmvc
二、@SpringBootApplication方式启动
启动类抽取出来,并且使用@ComponentScan进行controller的包扫描
三、springboot的启动原理
springmvc注解方式启动 内置http服务器(默认是tomcat)
四、@EnableAutoConfiguration作用
在这里启动springboot,只能访问到这个类本身的controller。因为,@EnableAutoConfiguration的扫包范围,默认在当前类里。
五、SpringApplication.run(App.class, args)的作用
它是整个程序入口,启动springboot项目。创建内置tomcat服务器,使用tomcat加载springmvc注解启动类。
六、@ComponentScan方式启动
@EnableAutoConfiguration配合上@ComponentScan使用
这个时候,controller包下的路径都可以访问到。
七、普遍形式
启动类只需要一个即可。那么,把启动类抽出来
八、@SpringBootApplication
@SpringBootApplication=@EnableAutoConfiguration+@ComponentScan
扫同级包和当前包。