Spring Boot:自动配置和项目

What is the Spring Boot?

Spring Boot is basically an extension of the Spring framework which eliminated the boilerplate configurations required for setting up a Spring application.
Indeed, you may find source code github, open source.

它对Spring平台持固执己见,为更快,更高效的开发生态系统铺平了道路。

这些组件(或bean)在Spring应用程序上下文中连接在一起以构成完整的应用程序,就像将砖,砂浆,木材,钉子,管道和电线绑在一起以组成房屋。

The act of wiring beans together is based on a pattern known as # dependency injection (DI). Rather than have components create and maintain the lifecycle of other beans that they depend on, a dependency-injected application relies on a separate entity (the container) to create and maintain all components and inject those into the beans that need them. This is done typically through constructor arguments or property accessor methods. More information you may download Spring, and Annotation resource.

Spring Boot Primary Goals

Provide a radically faster and widely accessible getting-started experience for all Spring development. Be opinionated out of the box but get out of the way quickly as requirements start to diverge from the defaults.
Alt Text

提供一系列大型项目通用的非功能性功能(例如嵌入式服务器,安全性,指标,运行状况检查和外部化配置)。 完全没有代码生成,也不需要XML配置。 Spring Boot的关键功能。 让我列出Spring Boot的一些关键功能,我们将讨论每个功能:

KEY FEATURES briefly

  • (步骤1)Spring Boot启动器(步骤2)Spring Boot自动配置(步骤3)完善的配置管理(步骤4)弹簧启动执行器(第5步)易于使用的嵌入式Servlet容器支持

(Step-1) Spring Boot starters

Spring Initialiser既是一个基于浏览器的Web应用程序,又是一个REST API,它们可以生成一个基本的Spring项目结构,您可以使用所需的任何功能充实自己。 使用Spring Initialiser的几种方法如下:

* From the web application at http://start.spring.io
* From the command line using the curl command
* From the command line using the Spring Boot command-line interface
* When creating a new project with Spring Tool Suite
* When creating a new project with IntelliJ IDEA
* When creating a new project with NetBeans

Alt Text

例如,spring-boot-starter-data-jpa启动程序模块包括使用Spring Data JPA所需的所有依赖项,以及Hibernate库的依赖项,因为Hibernate是最常用的JPA实现。

(Step-2) Spring Boot auto-configuration

Spring带有一个功能强大的Web框架,称为Spring MVC。 Spring MVC的中心是控制器的概念,它是一个处理请求并以某种信息进行响应的类。 Spring Boot通过基于各种标准注册bean,对应用程序有一个坚定的看法,并自动配置各种组件。 条件可以是:

  • 类路径中特定类的可用性有无春豆系统属性的存在缺少配置文件

Alt Text

小号pring MVC

例如,如果您的类路径中具有spring-webmvc依赖项,则Spring Boot假定您正在尝试构建基于SpringMVC的Web应用程序,并在尚未注册的情况下自动尝试注册Dispatcher Servlet。 如果类路径中有任何嵌入式数据库驱动程序(例如H2或HSQL),并且尚未显式配置DataSource bean,则Spring Boot将使用内存中的数据库设置自动注册DataSource bean。

(Step-3) Elegant configuration management

Spring supports externalizing configurable properties using the @PropertySource configuration.More information you may get .

Spring Boot通过使用合理的默认值和对bean属性的强大类型安全属性绑定,将其进一步扩展。 Spring Boot支持为不同的配置文件使用单独的配置文件,而无需进行许多配置。

(Step-4) Spring Boot actuator

Spring Boot执行器提供了各种各样的此类生产就绪功能,而无需开发人员编写大量代码。 弹簧执行器的一些功能包括:

  • 可以查看应用程序bean配置的详细信息可以查看应用程序URL映射,环境详细信息和配置参数值可以查看注册的健康检查指标

(Step-5) Easy-to-use embedded servlet container support

Easy to use embedded servlet container supports while building web applications, you need to create WAR type modules and then deploy them on external servers like Tomcat, WildFly, etc. But by using Spring Boot, you can create a JAR type module and embed the servlet container in the application very easily so that the application will be a self-contained deployment unit. Also, during development, you can easily run the Spring Boot JAR type module as a Java application from the IDE or from the command-line using a build tool like Maven or Gradle.
Servlet Containers
Servlet vs. Reactive more details

How to handle Default Context Path

如何更改默认上下文路径? 有几种更改默认上下文路径的方法。 使用application.properties文件

  • /src/main/resources/application.properties> server.port=8080> server.servlet.context-path=/springboot2webapp

默认情况下,上下文路径为“ /”。 要更改上下文路径,请覆盖并更新server.servlet.context-path属性。 以下示例将上下文路径从/更新到/ springboot2webapp或

Http://localhost:8080/springboot2webapp Just like many other configuration options, the context path in Spring Boot can be changed by setting a property, i.e., server.servlet.context-path.

from: https://dev.to//urunov/spring-boot-basics-and-fundamentals-with-projects-5967

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值