浅谈Spring和SpringBoot区别

2023-11-22 0 323

对于SpringSpringBoot到底有什么区别,我听到了很多答案,刚开始迈入学习SpringBoot的我当时也是一头雾水,随着经验的积累、我慢慢理解了这两个框架到底有什么区别,相信对于用了SpringBoot很久的同学来说,还不是很理解SpringBoot到底和Spring有什么区别,本篇文章为大家简单的介绍一下SpringSpringBoot区别。

一、看一下spring的3全部项目

spring 家族 有很多项目,springboot、spring framework、spring cloud等。

我们常用的也就是,springboot、springcloud、springsecurity、springdata。常说的 springmvc 只是spring framework 的特性之一。

二、springboot核心能力

1、内嵌 Servlet 容器,可以直接打成jar包,通过 java -jar xx.jar 运行项目。

2、提供 starter pom 系列,简化maven的依赖加载,减少依赖冲突的发生。

3、支持自动化配置,如下图。application.properties 文件在引入springboot和未引入springboot时,是不一样的。

实现的源码:springboot回去判断引入的jar包是否有 spring.factories 文件

@EnableAutoConfiguration
@Import({AutoConfigurationImportSelector.class})
protected List getCandidateConfigurations(AnnotationMetadata metadata, AnnotationAttributes attributes) {
 List configurations = SpringFactoriesLoader.loadFactoryNames(this.getSpringFactoriesLoaderFactoryClass(), this.getBeanClassLoader());
 Assert.notEmpty(configurations, "No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.");
 return configurations;
}

总结:springboot 是 spring 家族的一个项目,他的目标是提高使用者的开发效率。

本文来源:www.lxlinux.net/5583.html,若引用不当,请联系修改。

相关文章

猜你喜欢
官方客服团队

为您解决烦忧 - 24小时在线 专业服务

  • 0 +

    访问总数

  • 0 +

    会员总数

  • 0 +

    文章总数

  • 0 +

    今日发布

  • 0 +

    本周发布

  • 4975 +

    运行天数

你的前景,远超我们想象