Spring Boot的优势

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28831479/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 00:24:42  来源:igfitidea点击:

Advantage of Spring Boot

springspring-boot

提问by Ozum Safa

I have been trying to understand Spring Boot and maybe migrate my project to it. However I do not get the real advantage of it except the embedded Tomcat. Would you kindly explain to me what is the real power of Spring Boot compared to regular Spring?

我一直在尝试了解 Spring Boot 并可能将我的项目迁移到它。但是,除了嵌入式 Tomcat 之外,我没有得到它的真正优势。您能否向我解释一下与常规 Spring 相比,Spring Boot 的真正威力是什么?

回答by Arpit Aggarwal

Quoting from the Spring Boot Page, it has following features:

引用Spring Boot Page,它具有以下功能:

  1. Create stand-alone Spring applications
  2. Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)
  3. Provide opinionated 'starter' POMs to simplify your Maven configuration
  4. Automatically configure Spring whenever possible
  5. Provide production-ready features such as metrics, health checks and externalized configuration
  6. Absolutely no code generationand no requirement for XML configuration
  1. 创建独立的 Spring 应用程序
  2. 直接嵌入Tomcat、Jetty或Undertow(无需部署WAR文件)
  3. 提供自以为是的“入门”POM 以简化您的 Maven 配置
  4. 尽可能自动配置 Spring
  5. 提供生产就绪功能,例如指标、运行状况检查和外部化配置
  6. 完全不需要代码生成也不需要 XML 配置

回答by Cassian

The big advantage is out of the box configuration based on what it finds and server embedded (you can make a jar run it and go to localhost:8080to see the result) beside that it has metrics, health checks, externalised configuration, etc.

一大优势是基于其发现和服务器嵌入式箱配置了(你可以做一个罐子运行它,去localhost:8080看到的结果),其旁有metricshealth checksexternalised configuration,等。

In my opinion is the perfect tool for building cloud microservices.

在我看来是构建云微服务完美工具

回答by ConfusedCoder

Bootstrapping with defaults included in the configuration / jar-dependencies, is the real advantage of Spring boot! Get the things done quickly!

使用包含在配置/jar 依赖项中的默认值进行引导是 Spring Boot 的真正优势!快点把事情搞定!

Its just another project from Spring framework, where things look simplified, with strong support for Security, Data, Social etc all features you want for your application.

它只是来自 Spring 框架的另一个项目,其中的事情看起来很简单,并且对安全、数据、社交等所有您想要的应用程序功能提供了强大的支持。

If you prefer annotations over XML configuration like me you might use @Configurationfor configuration, @ComponentScanfor Dependency Injection, and @EnableAutoConfigurationto tell spring to guess the defaults and work along. The @SpringBootApplicationannotation is equivalent to using @Configuration, @EnableAutoConfiguration, and @ComponentScanwith their default attributes. So things further simplified, with a single annotation doing the work of 3.

如果你喜欢像我这样的 XML 配置的注释,你可以 @Configuration用于配置、 @ComponentScan依赖注入,并@EnableAutoConfiguration告诉 spring 猜测默认值并继续工作。该@SpringBootApplication注解相当于使用 @Configuration@EnableAutoConfiguration以及@ComponentScan与他们的默认属性。所以事情进一步简化,一个注释完成了 3 的工作。

回答by ci_

It's real easy to get something going from nothing, with loads of useful defaults.

从无到有非常容易,有大量有用的默认值。

Not so easy if you want to migrate some existing project which will most likely have developed a lot of quirks that are going to be difficult to migrate.

如果您想迁移一些现有项目,这些项目很可能已经开发了许多难以迁移的怪癖,这并不容易。

回答by K. Siva Prasad Reddy

Advantages of SpringBoot:

SpringBoot 的优点:

  • No need of creating boilerplate configuration
  • Plenty of SpringBoot Starter to quickly get up and running
  • DevTools to autorestart server on code/config updates
  • Embedded Tomcat/Jetty/Undertow support
  • Easier customization of application properties
  • Easy management of profile specific properties
  • Easier dependency management using platform-bom
  • 无需创建样板配置
  • 大量 SpringBoot Starter 快速启动和运行
  • DevTools 在代码/配置更新时自动重启服务器
  • 嵌入式 Tomcat/Jetty/Undertow 支持
  • 更轻松地自定义应用程序属性
  • 轻松管理配置文件特定属性
  • 使用 platform-b​​om 进行更轻松的依赖管理

Here are few of my articles on what are the advantages of SpringBoot and how SpringBoot works.

下面是我的几篇关于 SpringBoot 的优点和 SpringBoot 工作原理的文章。

Why SpringBoot?

为什么选择 SpringBoot?

How SpringBoot AutoConfiguration magic works?

SpringBoot AutoConfiguration 魔法是如何工作的?

回答by Santanu Dey

Biggest of all is that spring boot is aligned with the concept of microservices and can be run from a container anywhere e.g. cloud. This possible because the following nature of springboot

最重要的是,spring boot 符合微服务的概念,可以从任何地方的容器运行,例如云。这可能是因为 springboot 的以下性质

  • small footprint
  • standalone services
  • easier to launch from a container, each service can be in its own container (like docker)
  • easy to configure and deploy completely from a script. Good for auto-scaling and deploying in the cloud.
  • 占地面积小
  • 独立服务
  • 更容易从容器启动,每个服务都可以在自己的容器中(如 docker)
  • 易于完全从脚本配置和部署。适合在云中自动扩展和部署。

回答by jinjun.zhu

In active development,spring boot has the advantage of leave the complex xml file configure.

在积极的开发中,spring boot 的优势在于将复杂的 xml 文件配置好。

1.Embedded tomcat discard the web.xml configuration;

1.嵌入式tomcat丢弃web.xml配置;

2.spring-boot security discard the applicationcontext-security.xml configuration;

2.spring-boot security丢弃applicationcontext-security.xml配置;

3.spring-boot webservice discard the applicationcontext-ws.xml configuration;

3.spring-boot webservice丢弃applicationcontext-ws.xml配置;

4.spring-boot mvc discard the applicationcontext.xml configuration;

4.spring-boot mvc丢弃applicationcontext.xml配置;

5.spring-boot datasource(both Relational Database and nosql Database) discard the applicationcontext.xml configuration,even if more than one datasource.

5.spring-boot 数据源(关系数据库和 nosql 数据库)丢弃 applicationcontext.xml 配置,即使有多个数据源。

Discard this configuration file easy our development and improve the efficiency.

舍弃这个配置文件方便我们的开发,提高效率。