简体   繁体   English

了解 Spring Boot

[英]Understanding Spring Boot

I am trying to understand the difference between spring boot and spring boot web .我试图了解spring bootspring boot web之间的区别。 From this boot tutorial the pom contains spring boot as the parent and spring boot web as a dependency like so:从此引导教程中,pom 包含 spring boot 作为父项和 spring boot web 作为依赖项,如下所示:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.1.RELEASE</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

What are the uses for the 2 different versions? 2个不同版本的用途是什么? Do you always use them together?你总是一起使用它们吗? This spring boot documentation tells me if the program is production ready to use:这个 spring boot 文档告诉我该程序是否已准备好使用:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
</dependencies>

But if that's the case then why isn't there one for web like so:但如果是这样,那么为什么没有像这样的网络:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web-actuator</artifactId>
    </dependency>
</dependencies>

There are lots of these different 'starter' poms for spring boot.春季靴子有很多不同的“入门”poms。 Each one of them tells maven to bring in the dependencies needed for that particular functionality.它们中的每一个都告诉 maven 引入该特定功能所需的依赖项。 So spring-boot-starter-web brings in all the stuff needed for MVC and autoconfigures it with sensible defaults.所以spring-boot-starter-web引入了 MVC 所需的所有东西,并使用合理的默认值自动配置它。 The real trick to spring boot is it when it autoconfigures things it uses a whole of @ConditionalOnClass or other such annotations that look at what dependencies are on the classpath and provides configuration for those dependencies. spring boot 的真正诀窍在于,当它自动配置事物时,它使用整个@ConditionalOnClass或其他此类注解来查看类路径上的依赖项并为这些依赖项提供配置。 What this means is when you have that spring boot actuator starter, when it's doing its autoconfiguration it will look at what other spring boot start poms you have in your pom.xml and it will configure different endpoints for the actuator so you can see the various metrics the actuator provides for that particular module.这意味着当你有那个 spring boot actuator starter 时,当它进行自动配置时,它会查看你的pom.xml中还有哪些其他 spring boot start poms,它会为执行器配置不同的端点,这样你就可以看到各种执行器为该特定模块提供的指标。

Spring Boot is a framework, spring-boot-starter-web is one of the packages that comes with it, a jar file. Spring Boot是一个框架, spring-boot-starter-web是它自带的包之一,一个jar文件。

Just like JDK is a library, and util is one of the packages included in the JDK.就像JDK是一个库,而util是JDK中包含的包之一。

From: https://docs.spring.io来自: https ://docs.spring.io

Spring Boot provides a number of “Starters” that auto-configures your application adds jars to your classpath. Spring Boot 提供了许多“Starters”,可以自动配置您的应用程序,将 jar 添加到您的类路径中。 The spring-boot-starter-parent is a core starter that provides useful maven defaults. spring-boot-starter-parent 是一个核心启动器,提供有用的 maven 默认值。 It also provides a dependency-management section so that if you import additional starters then you can omit version tags for “blessed” dependencies.它还提供了一个依赖管理部分,这样如果你导入额外的启动器,那么你可以省略“有福”依赖的版本标签。 Therefore you should only need to specify the Spring Boot version number on this dependency因此,您只需要在此依赖项上指定 Spring Boot 版本号

Starters are a set of convenient dependency descriptors that you can include in your application considering each starter covers a specific area.The starters contain a lot of the dependencies that you need to get a project up and running quickly and with a consistent, supported set of managed transitive dependencies.For example, if you want to get started using Spring and JPA for database access, just include the "spring-boot-starter-data-jpa" dependency in your project, and you are good to go. Starters 是一组方便的依赖描述符,考虑到每个 starter 都覆盖特定区域,您可以将其包含在应用程序中。Starters 包含许多依赖项,您需要这些依赖项才能快速启动和运行项目,并具有一致的、受支持的集合管理传递依赖。例如,如果你想开始使用 Spring 和 JPA 进行数据库访问,只需在你的项目中包含“spring-boot-starter-data-jpa”依赖,你就可以开始了。 Spring Boot spring-boot-starter-web is starter for building web, including RESTful, applications using Spring MVC. Spring Boot spring-boot-starter-web 是使用 Spring MVC 构建 web(包括 RESTful 应用程序)的启动器。 It uses Tomcat as the default embedded container它使用 Tomcat 作为默认的嵌入式容器

Spring Boot has different groups of starters like Spring Boot 有不同的启动器组,比如

1- Spring Boot application starters : spring-boot-starter-web, spring-boot-starter-jdbc, spring-boot-starter-jpa etc 1- Spring Boot 应用程序启动器:spring-boot-starter-web、spring-boot-starter-jdbc、spring-boot-starter-jpa 等

2- Spring Boot production starters : spring-boot-starter-actuator which provides production ready features to help you monitor and manage your application 2- Spring Boot production starters :spring-boot-starter-actuator 提供生产就绪功能来帮助您监控和管理您的应用程序

3- Spring Boot technical starters : spring-boot-starter-jetty, spring-boot-starter-tomcat these starters can be used to exclude or swap specific technical facets 3- Spring Boot 技术启动器:spring-boot-starter-jetty、spring-boot-starter-tomcat 这些启动器可用于排除或交换特定的技术方面

1.spring-boot-starter-parent deals with the auto start of main method and run methods so on.. 2.and spring-boot-starter-web deals with the spring MVC things like controller, autowired so on.. Hope this helps.. 1.spring-boot-starter-parent 处理 main 方法的自动启动和 run 方法等等。2.spring-boot-starter-web 处理 spring MVC 的东西,比如控制器,自动装配等等。希望这个帮助..

Spring boot is a very cool tool of Spring Source. Spring Boot是Spring Source的一个非常酷的工具。 In many conference the team talck about of Spring Boot as one of the three DSR(Domain Specific Run-Time) of Pivotal.... Spring Boot, Spring XD and Grails(now Pivotal didn't support Groovy & Grails).在许多会议上,团队将 Spring Boot 视为 Pivotal 的三个 DSR(特定领域运行时)之一...... Spring Boot、Spring XD 和 Grails(现在 Pivotal 不支持 Groovy & Grails)。

That said compare Spring boot stand alone and Spring boot web enviroment may be a cool conversation.也就是说,比较独立的 Spring boot 和 Spring boot web 环境可能是一个很酷的话题。 First of all Spring boot give you many production ready istruments such as actuator(avaiable whit sprin boot in web enviroment), spring remote shall and so on.首先,Spring Boot 为您提供了许多生产就绪的工具,例如执行器(可在 Web 环境中使用 sprin boot)、spring remote 等。 The main difference is the same of had a spring stand-alone context or a Spring web context.主要区别在于具有 spring 独立上下文或 Spring web 上下文。 Of course some of the potentiality that yon could have are avaiable in a web context, Actuator is an example.当然,你可能拥有的一些潜力在网络环境中是可用的,Actuator 就是一个例子。 but the main difference is in what kind of application you need, web or stand-alone.但主要区别在于您需要哪种应用程序,网络应用程序还是独立应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM