springboot与spring比较区别

Crq
Crq
Crq
218
文章
0
评论
2021年5月2日02:06:48
评论
422 902字阅读3分0秒
摘要

面试的时候经常会被问到,spring和springboot的区别。或者SpringMVC和Springboot的区别。其实这样的问法就不是特别合适。因为spring、springboot、springmvc他们三个在spring体系中就不在同一个维度。

一、看一下spring的全部项目

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 家族的一个项目,他的目标是提高使用者的开发效率。

weinxin
我的微信
这是我的微信扫一扫
Crq
  • 本文由 发表于 2021年5月2日02:06:48
  • 转载请注明:https://www.cncrq.com/9159.html
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: