SpringBoot知识点简记

1,SpringBoot是什么?

SpringBoot其实就是Spring的一个子项目,SpringBoot可以用来来简化spring应用开发,约定大于配置,去繁从简,只需要运行就能创建一个独立的,产品级别的应用;

2,Spring Boot有哪些优点?

1,能够快速搭建独立运行的Spring项目,方便与其他框架集成;
2,使用的是嵌入式的Servlet无需打包成war包;
3,采用了大量的自动配置,简化了开发配置等等;

3,SpringBoot常用的启动器依赖(starter)有哪些?

spring-boot-starter-web 嵌入tomcat和web开发需要servlet与jsp支持
spring-boot-starter-data-jpa 数据库支持
spring-boot-starter-data-redis redis数据库支持
spring-boot-starter-data-solr solr支持
mybatis-spring-boot-starter 第三方的mybatis集成starter

4,SpringBoot实现自动配置原理?

SpringBoot搭建的项目中启动了中使用了@SpringBootApplication;此注解中有三个很关键的注解:
@SpringBootConfiguration:
组合了 @Configuration 注解,实现配置文件的功能
@EnableAutoConfiguration:
告诉Spring Boot基于你所添加的依赖,去“猜测”你想要如何配置Spring。
打开自动配置的功能,也可以关闭某个自动配置的选项,如关闭数据源自动配置功能
@ComponentScan:
配置组件扫描的指令:(此注解默认扫描启动类所在包及其子包)
这三个注解是SpringBoot自动配置的关键;

5,SpringBoot默认读取配置文件的方式?

springboot默认读取配置文件为application.properties或者是application.yml

6,SpringBoot如何集成Mybatis

1,首先导入相关启动器依赖;mybatis-spring-boot-starter
2,在Mybatis接口上加入@Mapper注解或者在启动类上加上@MapperScan(“接口所在包名”)
3,在application.yml配置数据源信息

7,开启SpringBoot特性有几种方式?

1,继承spring-boot-starter-parent项目
2,导入spring-boot-dependencies项目依赖

8,SpringBoot如何集成Swagger?

 swagger概念:
Swagger广泛用于可视化API,使用Swagger UI为前端开发人员提供在线沙箱。
Swagger是用于生成RESTful Web服务的可视化表示的工具,规范和完整框架实现;
集成swagger:
1,导入相关启动器依赖
<dependency>
   <groupId>io.springfox</groupId>
   <artifactId>springfox-swagger2</artifactId>
</dependency>
 <dependency>
     <groupId>io.springfox</groupId>
     <artifactId>springfox-swagger-ui</artifactId>
 </dependency>
2,编写swagger的config
@Configuration
@EnableSwagger2
public class Swagger2Configuration {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.xuecheng"))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("学成网api文档")
                .description("学成网api文档")
//                .termsOfServiceUrl("/")
                .version("1.0")
                .build();
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

liu.kai

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值