1.SpringBoot的启动类
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
其中 最突出的就是Annotation定义(@SpringBootApplication)和类定义(SpringApplication.run)
SpringBootApplication接口用到的注解
@Target(ElementType.TYPE) // 注解的适用范围,其中TYPE用于描述类、接口(包括包注解类型)或enum声明
@Retention(RetentionPolicy.RUNTIME) // 注解的生命周期,保留到class文件中(三个生命周期)
@Documented // 表明这个注解应该被javadoc记录
@Inherited // 子类可以继承该注解
@SpringBootConfiguration // 继承了Configuration,表示当前是注解类
@EnableAutoConfiguration // 开启springboot的注解功能,springboot的四大神器之一,其借助@import的帮助
@ComponentScan(excludeFilters = { // 扫描路径设置
@Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
public @interface SpringBootApplication {
...
}
重要的注解 分别是
-
@SpringBootConfiguration // 继承了Configuration,表示当前是注解类
标识当前类 会被扫描并加载到IOC容器中 -
@EnableAutoConfiguration // 这个我没看懂…等我 之后有时间慢慢看
开启springboot的注解功能,springboot的四大神器之一,其借助@import的帮助 -
@ComponentScan(excludeFilters = { // 扫描路径设置(具体使用待确认)
扫描 excludeFilters 路径下的 如:
1、@controller: controller控制器层(注入服务)
2、@service : service服务层(注入dao)
3、@repository : dao持久层(实现dao访问)
4、@component: 标注一个类为Spring容器的Bean,(把普通pojo实例化到spring容器中,相当于配置文件中的)
表示 此类标记为Spring容器中的一个Bean 加入到 IOC容器中
具体启动流程 建议参考 大佬文章https://www.cnblogs.com/theRhyme/p/11057233.html启动流程如图:
post方式:
当前端 获取数据 或者 指令时 :前端会将json或者thml格式的数据存入body缓冲区传到controller
get方式:
通过路径传递参数
然后:程序路线为:
controller层-----> service层(接口—>接口实现类) -----> dao层的.mapper文件 -----> 和mapper层里的.xml文件对应
Model层是数据层: TableName是对数据表实体的映射;
Criteria传输前台数据
DTO 传输类间数据
Mapper层 放置SQL查询XML文件
Dao层相当于XML文件的抽象类
然后就执行完了一步对前端数据的接受和处理