Springboot概略

Springboot

简介:

SpringBoot是由Pivotal团队在2013年开始研发、2014年4月发布第一个版本的全新开源的轻量级框架。它基于Spring4.0设计,不仅继承了Spring框架原有的优秀特性,而且还通过简化配置来进一步简化了Spring应用的整个搭建和开发过程。另外SpringBoot通过集成大量的框架使得依赖包的版本冲突,以及引用的不稳定性等问题得到了很好的解决。

特性:

  • 独立运行:可以创建独立的Spring应用程序,并且基于其Maven或Gradle插件,可以创建可执行的JARs和WARs,内嵌Tomcat或Jetty等Servlet容器;
  • 简化配置:提供自动配置的“starter”项目对象模型(POMS)以简化maven配置,尽可能自动配置Spring容器,提供准备好的特性,如指标、健康检查和外部化配置;
  • 无代码生成:绝对没有代码生成,不需要XML配置。一切借助注解来完成;
  • 应用监控: Springboot提供一系列端点可以监控服务及应用,做健康检测;

常用注解:

  • 核心注解
@SpringBootApplication//Springboot的核心注解包含了以下三个注解,一般在Application中配置该注解即可
@SpringBootConfiguration//组合了@Configuration 注解,实现配置文件的功能
@EnableAutoConfiguration//打开自动配置功能,也可在其中设置关闭功能
@ComponentScan//Spring组件扫描
  • 功能注解:
@Controller //控制器标注注解
@RequestMapping//常用作请求url注解,一般情况下在其中填入url地址,有时也在其中限制method的类型
@GetMapping//常用作Get请求url注解
@PostMapping//常用作Post请求url注解

Springboot常用POM依赖:

    <!--Springboot核心依赖-->
<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
<!--SpringBoot常用web依赖-->
<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
 </dependency>
<!--Springboot热部署工具-->
<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
</dependency>
<!--Springboot测试依赖-->
<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
<!--jdbc连接器-->
<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

本文章分类主要讲微服务部分,鉴于Springboot除配置文件以外核心内容基本与SSM相同,多余部分请参考Spring+SpringMVC+Mybatis

本人现役大四小白一枚,如有不足之处还望指正。

posted @ 2020-08-05 22:25  Aaron`Joe  阅读(174)  评论(0)    收藏  举报