简介

Spring Boot 用来简化 Spring 应用开发,约定大于配置,去繁从简,just run 就能创建一个独立的、产品级别的应用。

背景:

J2EE 笨重的开发、繁多的配置、低下的开发效率、复杂的部署流程、第三方技术集成难度大。

解决:

  • “Spring全家桶”时代。
  • Spring Boot -> J2EE 一站式解决方案。
  • Spring Cloud -> 分布式整体解决方案。

优点:

  • 可快速创建独立运行的 Spring 项目以及与主流框架集成。
  • 使用嵌入式的 Servlet 容器,应用无需打成 war 包。
  • starters 自动依赖于版本控制。
  • 大量的自动配置简化了开发,也可修改默认值。
  • 无需配置 XML,无代码生成,开箱即用。
  • 准生产环境的运行时实时监控。
  • 与云计算天然集成。

SpringBoot 官网 | SpringBoot 官方文档SpringBoot-2.1.3.RELEASE 源码下载(其它版本直接修改链接版本号即可)

HelloWorld

编码

1、使用 maven 创建一个 java 项目,依赖如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
        <relativePath/>
    </parent>
    <groupId>com.zze.learning</groupId>
    <artifactId>springboot_helloworld</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <java.version>1.8</java.version>
    </properties>

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

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

    <build>
        <plugins>
            <!--这个插件,可以将应用打包成一个可执行的 jar 包-->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

pom.xml

2、编写 SpringMVC 控制器:

package com.zze.springboot.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TestController {
    @RequestMapping("/test")
    @ResponseBody
    public String test(){
        return "hello world";
    }
}

com.zze.springboot.controller.TestController

3、编写主程序:

package com.zze.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication // 标注一个主程序类,说明这是一个 Spring Boot 应用
public class TestApplication {
    public static void main(String[] args) {
        // Spring 应用启动
        SpringApplication.run(TestApplication.class, args);
    }
}

com.zze.springboot.TestApplication

4、执行主程序:

控制台:

浏览器访问 localhost:8080/test:

效果

5、我们还可以通过 maven 将程序打成一个 jar 包,直接通过 java 命令启动:

CMD:

浏览器访问 localhost:8080/test:

效果

这个 HelloWorld 程序也可以使用官网帮助生成,点击使用

探究

pom文件

  • 父项目

    首先,我们引入了一个父项目:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
        <relativePath/>
    </parent>

    而这个父项目也有一个父项目:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>2.1.3.RELEASE</version>
        <relativePath>../../spring-boot-dependencies</relativePath>
    </parent>

    这个父项目是真正管理 SpringBoot 应用中的所有依赖版本,它可以称为 SpringBoot 的版本管理中心,所以以后我们导入它管理的依赖是不需要声明版本的。

  • 场景启动器

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

    该依赖帮我们导入了 web 模块正常运行所依赖的组件。

    spring-boot-starter:SpingBoot 场景启动器。SpringBoot 将所有功能场景都抽取出来,做成一个个 starter (场景启动器),只需要在项目中引入这些 starter 相关场景的所有依赖都会导入进来,要使用什么功能就导入什么场景启动器。下面是 SpringBoot 提供的一些场景启动器:

    Name Description Pom

    spring-boot-starter

    Core starter, including auto-configuration support, logging and YAML

    Pom

    spring-boot-starter-activemq

    Starter for JMS messaging using Apache ActiveMQ

    Pom

    spring-boot-starter-amqp

    Starter for using Spring AMQP and Rabbit MQ

    Pom

    spring-boot-starter-aop

    Starter for aspect-oriented programming with Spring AOP and AspectJ

    Pom

    spring-boot-starter-artemis

    Starter for JMS messaging using Apache Artemis

    Pom

    spring-boot-starter-batch

    Starter for using Spring Batch

    Pom

    spring-boot-starter-cache

    Starter for using Spring Framework’s caching support

    Pom

    spring-boot-starter-cloud-connectors

    Starter for using Spring Cloud Connectors which simplifies connecting to services in cloud platforms like Cloud Foundry and Heroku

    Pom

    spring-boot-starter-data-cassandra

    Starter for using Cassandra distributed database and Spring Data Cassandra

    Pom

    spring-boot-starter-data-cassandra-reactive

    Starter for using Cassandra distributed database and Spring Data Cassandra Reactive

    Pom

    spring-boot-starter-data-couchbase

    Starter for using Couchbase document-oriented database and Spring Data Couchbase

    Pom

    spring-boot-starter-data-couchbase-reactive

    Starter for using Couchbase document-oriented database and Spring Data Couchbase Reactive

    Pom

    spring-boot-starter-data-elasticsearch

    Starter for using Elasticsearch search and analytics engine and Spring Data Elasticsearch

    Pom

    spring-boot-starter-data-jdbc

    Starter for using Spring Data JDBC

    Pom

    spring-boot-starter-data-jpa

    Starter for using Spring Data JPA with Hibernate

    Pom

    spring-boot-starter-data-ldap

    Starter for using Spring Data LDAP

    Pom

    spring-boot-starter-data-mongodb

    Starter for using MongoDB document-oriented database and Spring Data MongoDB

    Pom

    spring-boot-starter-data-mongodb-reactive

    Starter for using MongoDB document-oriented database and Spring Data MongoDB Reactive

    Pom

    spring-boot-starter-data-neo4j

    Starter for using Neo4j graph database and Spring Data Neo4j

    Pom

    spring-boot-starter-data-redis

    Starter for using Redis key-value data store with Spring Data Redis and the Lettuce client

    Pom

    spring-boot-starter-data-redis-reactive

    Starter for using Redis key-value data store with Spring Data Redis reactive and the Lettuce client

    Pom

    spring-boot-starter-data-rest

    Starter for exposing Spring Data repositories over REST using Spring Data REST

    Pom

    spring-boot-starter-data-solr

    Starter for using the Apache Solr search platform with Spring Data Solr

    Pom

    spring-boot-starter-freemarker

    Starter for building MVC web applications using FreeMarker views

    Pom

    spring-boot-starter-groovy-templates

    Starter for building MVC web applications using Groovy Templates views

    Pom

    spring-boot-starter-hateoas

    Starter for building hypermedia-based RESTful web application with Spring MVC and Spring HATEOAS

    Pom

    spring-boot-starter-integration

    Starter for using Spring Integration

    Pom

    spring-boot-starter-jdbc

    Starter for using JDBC with the HikariCP connection pool

    Pom

    spring-boot-starter-jersey

    Starter for building RESTful web applications using JAX-RS and Jersey. An alternative to spring-boot-starter-web

    Pom

    spring-boot-starter-jooq

    Starter for using jOOQ to access SQL databases. An alternative to spring-boot-starter-data-jpa or spring-boot-starter-jdbc

    Pom

    spring-boot-starter-json

    Starter for reading and writing json

    Pom

    spring-boot-starter-jta-atomikos

    Starter for JTA transactions using Atomikos

    Pom

    spring-boot-starter-jta-bitronix

    Starter for JTA transactions using Bitronix

    Pom

    spring-boot-starter-mail

    Starter for using Java Mail and Spring Framework’s email sending support

    Pom

    spring-boot-starter-mustache

    Starter for building web applications using Mustache views

    Pom

    spring-boot-starter-oauth2-client

    Starter for using Spring Security’s OAuth2/OpenID Connect client features

    Pom

    spring-boot-starter-oauth2-resource-server

    Starter for using Spring Security’s OAuth2 resource server features

    Pom

    spring-boot-starter-quartz

    Starter for using the Quartz scheduler

    Pom

    spring-boot-starter-security

    Starter for using Spring Security

    Pom

    spring-boot-starter-test

    Starter for testing Spring Boot applications with libraries including JUnit, Hamcrest and Mockito

    Pom

    spring-boot-starter-thymeleaf

    Starter for building MVC web applications using Thymeleaf views

    Pom

    spring-boot-starter-validation

    Starter for using Java Bean Validation with Hibernate Validator

    Pom

    spring-boot-starter-web

    Starter for building web, including RESTful, applications using Spring MVC. Uses Tomcat as the default embedded container

    Pom

    spring-boot-starter-web-services

    Starter for using Spring Web Services

    Pom

    spring-boot-starter-webflux

    Starter for building WebFlux applications using Spring Framework’s Reactive Web support

    Pom

    spring-boot-starter-websocket

    Starter for building WebSocket applications using Spring Framework’s WebSocket support

    Pom

主程序类

package com.zze.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication // 标注一个主程序类,说明这是一个 Spring Boot 应用
public class TestApplication {
    public static void main(String[] args) {
        // Spring 应用启动
        SpringApplication.run(TestApplication.class, args);
    }
}

@SpringBootApplication :标注在某个类上说明这个类是 SpringBoot 的主配置类,SpringBoot 就应该运行这个类的 main 方法来启动 SpringBoot 应用。查看它,发现它其实是一个组合注解:

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(
    excludeFilters = {@Filter(
    type = FilterType.CUSTOM,
    classes = {TypeExcludeFilter.class}
), @Filter(
    type = FilterType.CUSTOM,
    classes = {AutoConfigurationExcludeFilter.class}
)}
)
public @interface SpringBootApplication {
  • @SpringBootConfiguration :标注在某个类上,表示这是一个 SpringBoot 的配置类。而它也是一个组合注解:

    @Target({ElementType.TYPE})
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    @Configuration
    public @interface SpringBootConfiguration {
    • @Configuration :Spring 配置类上来标注这个注解。它其实是容器中的一个组件:

      @Target({ElementType.TYPE})
      @Retention(RetentionPolicy.RUNTIME)
      @Documented
      @Component
      public @interface Configuration {
@EnableAutoConfiguration :开启自动配置功能。以前我们需要配置的部分,SpringBoot 帮我们自动配置。查看它:

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@AutoConfigurationPackage
@Import(AutoConfigurationImportSelector.class)
public @interface EnableAutoConfiguration {
  • @AutoConfigurationPackage :自动配置包注解。

    @Target(ElementType.TYPE)
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    @Inherited
    @Import(AutoConfigurationPackages.Registrar.class)
    public @interface AutoConfigurationPackage {
    • @Import(AutoConfigurationPackages.Registrar.class) :Spring 底层注解,给容器中导入组件。导入的组件由 AutoConfigurationPackages.Registrar.class 决定,使用这个类会将所标识类(即: com.zze.springboot.TestApplication 类)所在包及子包下的所有类扫描到 Spring 容器。

      @Target({ElementType.TYPE})
      @Retention(RetentionPolicy.RUNTIME)
      @Documented
      public @interface Import {
  • @Import(AutoConfigurationImportSelector.class) :Spring 底层注解,给容器中导入组件。 AutoConfigurationImportSelector.class 会将要导入的组件以全类名方式返回,这些组件就会被添加到容器中。最终会给容器中导入很多自动配置类,这些自动配置类的作用就是给容器中导入这个场景需要的所有组件,并配置好这些组件。有了自动配置类,免去了我们手动编写配置注入功能组件等工作。这些自动配置类全路径名放在哪里呢?查看源码会发现,这些类的全路径名是从类路径下 META-INF/spring.factories 中读取。

    # Initializers
    org.springframework.context.ApplicationContextInitializer=\
    org.springframework.boot.autoconfigure.SharedMetadataReaderFactoryContextInitializer,\
    org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener
    
    # Application Listeners
    org.springframework.context.ApplicationListener=\
    org.springframework.boot.autoconfigure.BackgroundPreinitializer
    
    # Auto Configuration Import Listeners
    org.springframework.boot.autoconfigure.AutoConfigurationImportListener=\
    org.springframework.boot.autoconfigure.condition.ConditionEvaluationReportAutoConfigurationImportListener
    
    # Auto Configuration Import Filters
    org.springframework.boot.autoconfigure.AutoConfigurationImportFilter=\
    org.springframework.boot.autoconfigure.condition.OnBeanCondition,\
    org.springframework.boot.autoconfigure.condition.OnClassCondition,\
    org.springframework.boot.autoconfigure.condition.OnWebApplicationCondition
    
    # Auto Configure
    org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
    org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration,\
    org.springframework.boot.autoconfigure.aop.AopAutoConfiguration,\
    org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration,\
    org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration,\
    org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration,\
    org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration,\
    org.springframework.boot.autoconfigure.cloud.CloudServiceConnectorsAutoConfiguration,\
    org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration,\
    org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration,\
    org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration,\
    org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration,\
    org.springframework.boot.autoconfigure.dao.PersistenceExceptionTranslationAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveDataAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveRepositoriesAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.couchbase.CouchbaseReactiveDataAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.couchbase.CouchbaseReactiveRepositoriesAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.jdbc.JdbcRepositoriesAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.ldap.LdapRepositoriesAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.mongo.MongoReactiveRepositoriesAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.solr.SolrRepositoriesAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.redis.RedisReactiveAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration,\
    org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration,\
    org.springframework.boot.autoconfigure.elasticsearch.jest.JestAutoConfiguration,\
    org.springframework.boot.autoconfigure.elasticsearch.rest.RestClientAutoConfiguration,\
    org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration,\
    org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration,\
    org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration,\
    org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration,\
    org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration,\
    org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration,\
    org.springframework.boot.autoconfigure.hazelcast.HazelcastJpaDependencyAutoConfiguration,\
    org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration,\
    org.springframework.boot.autoconfigure.http.codec.CodecsAutoConfiguration,\
    org.springframework.boot.autoconfigure.influx.InfluxDbAutoConfiguration,\
    org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration,\
    org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration,\
    org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration,\
    org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,\
    org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration,\
    org.springframework.boot.autoconfigure.jdbc.JndiDataSourceAutoConfiguration,\
    org.springframework.boot.autoconfigure.jdbc.XADataSourceAutoConfiguration,\
    org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration,\
    org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration,\
    org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration,\
    org.springframework.boot.autoconfigure.jms.JndiConnectionFactoryAutoConfiguration,\
    org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration,\
    org.springframework.boot.autoconfigure.jms.artemis.ArtemisAutoConfiguration,\
    org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration,\
    org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration,\
    org.springframework.boot.autoconfigure.jooq.JooqAutoConfiguration,\
    org.springframework.boot.autoconfigure.jsonb.JsonbAutoConfiguration,\
    org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration,\
    org.springframework.boot.autoconfigure.ldap.embedded.EmbeddedLdapAutoConfiguration,\
    org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration,\
    org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration,\
    org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration,\
    org.springframework.boot.autoconfigure.mail.MailSenderValidatorAutoConfiguration,\
    org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration,\
    org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration,\
    org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration,\
    org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration,\
    org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration,\
    org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration,\
    org.springframework.boot.autoconfigure.reactor.core.ReactorCoreAutoConfiguration,\
    org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration,\
    org.springframework.boot.autoconfigure.security.servlet.SecurityRequestMatcherProviderAutoConfiguration,\
    org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration,\
    org.springframework.boot.autoconfigure.security.servlet.SecurityFilterAutoConfiguration,\
    org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration,\
    org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration,\
    org.springframework.boot.autoconfigure.sendgrid.SendGridAutoConfiguration,\
    org.springframework.boot.autoconfigure.session.SessionAutoConfiguration,\
    org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientAutoConfiguration,\
    org.springframework.boot.autoconfigure.security.oauth2.client.reactive.ReactiveOAuth2ClientAutoConfiguration,\
    org.springframework.boot.autoconfigure.security.oauth2.resource.servlet.OAuth2ResourceServerAutoConfiguration,\
    org.springframework.boot.autoconfigure.security.oauth2.resource.reactive.ReactiveOAuth2ResourceServerAutoConfiguration,\
    org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration,\
    org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration,\
    org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration,\
    org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration,\
    org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration,\
    org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration,\
    org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration,\
    org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration,\
    org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration,\
    org.springframework.boot.autoconfigure.web.reactive.HttpHandlerAutoConfiguration,\
    org.springframework.boot.autoconfigure.web.reactive.ReactiveWebServerFactoryAutoConfiguration,\
    org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration,\
    org.springframework.boot.autoconfigure.web.reactive.error.ErrorWebFluxAutoConfiguration,\
    org.springframework.boot.autoconfigure.web.reactive.function.client.ClientHttpConnectorAutoConfiguration,\
    org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration,\
    org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration,\
    org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration,\
    org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration,\
    org.springframework.boot.autoconfigure.web.servlet.HttpEncodingAutoConfiguration,\
    org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration,\
    org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration,\
    org.springframework.boot.autoconfigure.websocket.reactive.WebSocketReactiveAutoConfiguration,\
    org.springframework.boot.autoconfigure.websocket.servlet.WebSocketServletAutoConfiguration,\
    org.springframework.boot.autoconfigure.websocket.servlet.WebSocketMessagingAutoConfiguration,\
    org.springframework.boot.autoconfigure.webservices.WebServicesAutoConfiguration,\
    org.springframework.boot.autoconfigure.webservices.client.WebServiceTemplateAutoConfiguration
    
    # Failure analyzers
    org.springframework.boot.diagnostics.FailureAnalyzer=\
    org.springframework.boot.autoconfigure.diagnostics.analyzer.NoSuchBeanDefinitionFailureAnalyzer,\
    org.springframework.boot.autoconfigure.jdbc.DataSourceBeanCreationFailureAnalyzer,\
    org.springframework.boot.autoconfigure.jdbc.HikariDriverConfigurationFailureAnalyzer,\
    org.springframework.boot.autoconfigure.session.NonUniqueSessionRepositoryFailureAnalyzer
    
    # Template availability providers
    org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider=\
    org.springframework.boot.autoconfigure.freemarker.FreeMarkerTemplateAvailabilityProvider,\
    org.springframework.boot.autoconfigure.mustache.MustacheTemplateAvailabilityProvider,\
    org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAvailabilityProvider,\
    org.springframework.boot.autoconfigure.thymeleaf.ThymeleafTemplateAvailabilityProvider,\
    org.springframework.boot.autoconfigure.web.servlet.JspTemplateAvailabilityProvider

    spring-boot-autoconfigure-2.1.3.RELEASE.jar!/META-INF/spring.factories

    J2EE的整体解决方案和自动配置都在 spring-boot-autoconfigure-2.1.3.RELEASE.jar 中。

Spring Initializr

IDE 都支持使用 Spring 的项目创建向导快速创建一个 SpringBoot 项目(需联网环境下)。下面以 IDEA 为例。

使用

1、新建模块,选中 “Spring Initializr” 项:

2、输入坐标,默认选择 “Maven Project”:

3、可直接勾选要导入的场景:

4、点击“Finish”,完成:

目录结构

默认生成的 SpringBoot 项目:

  • 主程序已经生成好了,我们只需要编写需要的逻辑。
  • resources 文件夹中目录结构:
    static:保存所有的静态资源,例如:js、css、images 等。
    templates:保存所有的模板页面;(SpringBoot 以 jar 包方式嵌入Tomcat,默认不支持 JSP 页面,可使用模板引擎如:freemarker、thymeleaf)。
    application.properties:SpringBoot 应用的配置文件,可以修改一些默认设置。

最新文章

  1. Spark——SparkContext简单分析
  2. CentOS光盘挂载命令以及安装软件
  3. 海思H264解码库 hi_h264dec_w.dll 水印问题
  4. python jenkins-api,jira crowd. email-servers
  5. Deep Learning 18:DBM的学习及练习_读论文“Deep Boltzmann Machines”的笔记
  6. ASP.NT运行原理和页面生命周期详解及其应用
  7. SQL Server添加MDW性能监控报表(转载)
  8. EF6+MYSQL之初体验
  9. tcpdump常用命令
  10. 一台机器,运行两个mysql版本 实例
  11. 字符串在 UNICODE、MBCS编码下面的区别
  12. 为Android系统的Application Frameworks层增加硬件访问服务
  13. 内存数据网格hazelcast的一些机制原理
  14. Taro 列表循环--点赞功能图片切换
  15. C# CountdownEvent实现
  16. php7连接 sqlserver踩过的坑,could not find driver解决方式
  17. 艰苦的编译boost python (失败)
  18. (转)live555学习笔记7-RTP打包与发送
  19. js 获取上传文件的字节数及内容
  20. 一个ASP.NET中使用的MessageBox类

热门文章

  1. Unity3D中录制和输出wav文件
  2. asp.net mvc 根据浏览器判断,如果是微信浏览器则进行网页授权,否则直接访问
  3. (10) 如何MySQL读压力大的问题
  4. PON
  5. bat搜集
  6. 第四百零三节,python网站在线支付,支付宝接口集成与远程调试,
  7. python定义函数时,形参前加*和**的意义
  8. 81For全栈技术网
  9. JavaScript 运行机制详解:Event Loop
  10. 【Py-Github】根据条件筛选Github repo的例子