您当前的位置:首页 > 电脑百科 > 程序开发 > 框架

初识SpringBoot Starter

时间:2022-07-12 16:44:25  来源:  作者:IT食者

什么是Starter

starter 是springboot 的核心,每个starter负责实现特定的功能,使用者只需引入starter即可自动配置,无需关心框架整合带来的问题。

Starter 项目结构

src
 |- main
     |- JAVA
     |- resources
          |- META-INF
               |--spring.factories
pom.xml

spring.factories

## Initializers
## ApplicationContextInitializer接口的作用是可以在ApplicationContext初始化之前,对Spring上下文属性进行修改,既refresh()前的一个钩子函数。
org.springframework.context.ApplicationContextInitializer

## Application Listeners
## ApplicationListener 是Spring的监听器,可以通过对Spring上下文发送消息事件(由ApplicationContext. publishEvent进行消息发送),由对应的监听器进行捕获处理。 
org.springframework.context.ApplicationListener

## Auto Configuration Import Listeners
## 当Spring使用ConfigurationClassParser加载完所有@Configuration后会再一次使用AutoConfigurationImportSelector排除所有不符合条件的@Configuration,排除完后则回调所有AutoConfigurationImportListener的监听器。可相当于加载并过滤完@Configuration后的钩子回调。
org.springframework.boot.autoconfigure.AutoConfigurationImportListener

# Auto Configuration Import Filters
# 为 org.springframework.boot.autoconfigure.EnableAutoConfiguration定义的所有配置类增加ImportFilter来决定是否进行配置
org.springframework.boot.autoconfigure.AutoConfigurationImportFilter

# Auto Configure
# 定义自动装配config类,当系统引入该jar包时, spring上下文将初始化这些config类
org.springframework.boot.autoconfigure.EnableAutoConfiguration

# Failure analyzers
# 当spring bean的调用方法抛出特定异常时由自定义的特定FailureAnalyzer进行捕获并且进行处理。
org.springframework.boot.diagnostics.FailureAnalyzer

pom.xml

之后的章节中只写<dependencies> 节点

<?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">
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.4.RELEASE</version>
  </parent>
  
  <modelVersion>4.0.0</modelVersion>  
  <name>demo-spring-boot-starter</name>
  <groupId>com.v5ba</groupId>
  <artifactId>demo-spring-boot-starter</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>

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

官方starter

  • spring-boot-starter 这是Spring Boot的核心启动器,包含了自动配置、日志和YAML。
  • spring-boot-starter-actuator 帮助监控和管理应用。
  • spring-boot-starter-amqp 通过spring-rabbit来支持AMQP协议(Advanced Message Queuing Protocol)。
  • spring-boot-starter-aop 支持面向方面的编程即AOP,包括spring-aop和AspectJ。
  • spring-boot-starter-artemis 通过Apache Artemis支持JMS的API(Java Message Service API)。
  • spring-boot-starter-batch 支持Spring Batch,包括HSQLDB数据库。
  • spring-boot-starter-cache 支持Spring的Cache抽象。
  • spring-boot-starter-cloud-connectors 支持Spring Cloud Connectors,简化了在像Cloud Foundry或Heroku这样的云平台上连接服务。
  • spring-boot-starter-data-elasticsearch 支持ElasticSearch搜索和分析引擎,包括spring-data-elasticsearch。
  • spring-boot-starter-data-gemfire 支持GemFire分布式数据存储,包括spring-data-gemfire。
  • spring-boot-starter-data-jpa 支持JPA(Java Persistence API),包括spring-data-jpa、spring-orm、hibernate。
  • spring-boot-starter-data-MongoDB 支持MongoDB数据,包括spring-data-mongodb。
  • spring-boot-starter-data-rest 通过spring-data-rest-webmvc,支持通过REST暴露Spring Data数据仓库。
  • spring-boot-starter-data-solr 支持Apache Solr搜索平台,包括spring-data-solr。
  • spring-boot-starter-freemarker 支持FreeMarker模板引擎。
  • spring-boot-starter-groovy-templates 支持Groovy模板引擎。
  • spring-boot-starter-hateoas 通过spring-hateoas支持基于HATEOAS的RESTful Web服务。
  • spring-boot-starter-ho.NETq 通过HornetQ支持JMS。
  • spring-boot-starter-integration 支持通用的spring-integration模块。
  • spring-boot-starter-jdbc 支持JDBC数据库。
  • spring-boot-starter-jersey 支持Jersey RESTful Web服务框架。
  • spring-boot-starter-jta-atomikos 通过Atomikos支持JTA分布式事务处理。
  • spring-boot-starter-jta-bitronix 通过Bitronix支持JTA分布式事务处理。
  • spring-boot-starter-mail 支持javax.mail模块。
  • spring-boot-starter-mobile 支持spring-mobile。
  • spring-boot-starter-mustache 支持Mustache模板引擎。
  • spring-boot-starter-redis 支持Redis键值存储数据库,包括spring-redis。
  • spring-boot-starter-security 支持spring-security。
  • spring-boot-starter-social-facebook 支持spring-social-facebook
  • spring-boot-starter-social-linkedin 支持pring-social-linkedin
  • spring-boot-starter-social-twitter 支持pring-social-twitter
  • spring-boot-starter-test 支持常规的测试依赖,包括JUnit、Hamcrest、Mockito以及spring-test模块。
  • spring-boot-starter-thymeleaf 支持Thymeleaf模板引擎,包括与Spring的集成。
  • spring-boot-starter-velocity 支持Velocity模板引擎。
  • spring-boot-starter-web S支持全栈式Web开发,包括Tomcat和spring-webmvc。
  • spring-boot-starter-websocket 支持WebSocket开发。
  • spring-boot-starter-ws 支持Spring Web Services。
  • spring-boot-starter-actuator 增加了面向产品上线相关的功能,比如测量和监控。
  • spring-boot-starter-remote-shell 增加了远程ssh shell的支持。
  • spring-boot-starter-jetty 引入了Jetty HTTP引擎(用于替换Tomcat)。
  • spring-boot-starter-log4j 支持Log4J日志框架。
  • spring-boot-starter-logging 引入了Spring Boot默认的日志框架Logback。
  • spring-boot-starter-tomcat 引入了Spring Boot默认的HTTP引擎Tomcat。
  • spring-boot-starter-undertow 引入了Undertow HTTP引擎(用于替换Tomcat)。


Tags:SpringBoot   点击:()  评论:()
声明:本站部分内容及图片来自互联网,转载是出于传递更多信息之目的,内容观点仅代表作者本人,如有任何标注错误或版权侵犯请与我们联系(Email:2595517585@qq.com),我们将及时更正、删除,谢谢。
▌相关推荐
本文主要讲解如何在Springboot中逐步实现对mybatis的集成应用。1、引入依赖在pom.xml文件中引入mybatis依赖。// pom.xml <dependency> <groupId>org.mybatis.spring.boo...【详细内容】
2022-11-02  Tags: SpringBoot  点击:(4)  评论:(0)  加入收藏
一、自动注入没有添加泛型问题自定义RedisTemplate<String,Object>后,在使用时,需要在自动注入的RedisTemplate中添加泛型为RedisTemplate<String,Object>,否则会报错:com.fast...【详细内容】
2022-11-01  Tags: SpringBoot  点击:(5)  评论:(0)  加入收藏
概念IOC:控制反转。从前需要在程序中创建对象实例;现在则通过一个外部的容器统一动态创建spring IOC 容器中的实例如何动态加载Condition:只有在特定条件满足时才加载举例 @Con...【详细内容】
2022-10-10  Tags: SpringBoot  点击:(103)  评论:(0)  加入收藏
简介在项目中,存在传递超大 json 数据的场景。直接传输超大 json 数据的话,有以下两个弊端 占用网络带宽,而有些云产品就是按照带宽来计费的,间接浪费了钱 传输数据大导致网络...【详细内容】
2022-10-10  Tags: SpringBoot  点击:(33)  评论:(0)  加入收藏
前言最近自己用Spring Cloud Alibaba做了一个微服务架构的项目,部署的时候遇到了难题:内存不够。目前该项目有7个微服务,因为我只有一台阿里云的服务器(2C 4G),所以我只能把所有...【详细内容】
2022-10-06  Tags: SpringBoot  点击:(32)  评论:(0)  加入收藏
关于NettyNetty 是一个利用 Java 的高级网络的能力,隐藏其背后的复杂性而提供一个易于使用的 API 的客户端/服务器框架。MAVEN依赖 <dependencies> <!-- https://mvnrepos...【详细内容】
2022-09-27  Tags: SpringBoot  点击:(27)  评论:(0)  加入收藏
因业务需要, 公司内需要使用 SpringBoot Starter 构建 SDK. 不同的是使用了更为灵活的 Kotlin 语言, 构建脚本也换成了 Kotlin Script. 框架: SpringBoot 业务代码语言: Kot...【详细内容】
2022-09-27  Tags: SpringBoot  点击:(36)  评论:(0)  加入收藏
一、下载MinIo的地址https://min.io/download#/windows二、如何进行启动 绝对路径\minio.exe server F:\Data --console-address ":9001" 访问页面http://192.168.1.100:90...【详细内容】
2022-09-26  Tags: SpringBoot  点击:(65)  评论:(0)  加入收藏
姿势1:ThreadLocal+TaskDecorator用户工具类/** *使用ThreadLocal存储共享的数据变量,如登录的用户信息 */public class UserUtils { private static final ThreadLocal<...【详细内容】
2022-09-16  Tags: SpringBoot  点击:(68)  评论:(0)  加入收藏
添加依赖 org.springframework.boot spring-boot-starter-logging 在yml配置文件中添加配置应用配置文件logging: config: classpath: logback.xml 配置logback.xml文件信...【详细内容】
2022-09-16  Tags: SpringBoot  点击:(135)  评论:(0)  加入收藏
▌简易百科推荐
这篇文章中我们将会介绍Spring的框架以及本体内容,包括核心容器,注解开发,AOP以及事务等内容那么简单说明一下Spring的必要性: Spring技术是JavaEE开发的必备技能,企业开发技术...【详细内容】
2022-11-03  嘻呱互联   网易号  Tags:Spring   点击:(5)  评论:(0)  加入收藏
本文主要讲解如何在Springboot中逐步实现对mybatis的集成应用。1、引入依赖在pom.xml文件中引入mybatis依赖。// pom.xml <dependency> <groupId>org.mybatis.spring.boo...【详细内容】
2022-11-02  高道天    Tags:SpringBoot   点击:(4)  评论:(0)  加入收藏
真正的大师,永远都怀着一颗学徒的心!一、项目简介Vue2/Vue3前后端分离开发框架二、实现功能 支持移动端和pc端 支持自动生成代码 支持各种图表表单 支持树形菜单 支持...【详细内容】
2022-11-02  菜鸟程序猿  今日头条  Tags:Vue2   点击:(1)  评论:(0)  加入收藏
一、自动注入没有添加泛型问题自定义RedisTemplate<String,Object>后,在使用时,需要在自动注入的RedisTemplate中添加泛型为RedisTemplate<String,Object>,否则会报错:com.fast...【详细内容】
2022-11-01  德才兼备清风Q  今日头条  Tags:Springboot   点击:(5)  评论:(0)  加入收藏
在考虑 笔记本 或者 显示器 默认设置125%或者150%缩放,导致布局错乱的解决方法 一、为什么会出现有这个问题? 因为现在很多14寸的笔记本,出厂默认就是150%的显示。导致很多时...【详细内容】
2022-11-01  零端阿飞  今日头条  Tags:vue   点击:(11)  评论:(0)  加入收藏
我们将研究 request-validator 库,它能够将用户输入与预定义的一组规则(如 required、max、min、email 等)进行比较。我们有时会遇到由于用户提供的输入长于数据库列大小甚至不...【详细内容】
2022-10-31  qaseven  今日头条  Tags:Spring Boot   点击:(6)  评论:(0)  加入收藏
Svelte 的优点 代码是根据说明在没有额外运输规格的情况下生成的。 它将指令转换为强大的运行时语言。 它运行代码并优化代码生成,速度相比React、vue的运行资源消耗小很多...【详细内容】
2022-10-29  三维棱镜prism3dcn  今日头条  Tags:Svelte   点击:(9)  评论:(0)  加入收藏
一、Forest1.1 业务需求一般情况下是后端提供接口,前端调用,解决需求,但是有的时候为了方便,复用别人的接口(网上的,公共的第三方接口(短信、天气等)),就出现了后端调用后端接口的情况...【详细内容】
2022-10-27  程序猿阿嘴  今日头条  Tags:Forest   点击:(20)  评论:(0)  加入收藏
为了k8s和别的程序不起冲突,默认端口的范围是 30000-32767 ,这里面我们可以手动修改api-server的配置,缺点是可能占用其它程序的端口或者与其他程序的端口产生冲突。1、方法:修...【详细内容】
2022-10-25  gongjing2012  今日头条  Tags:K8S   点击:(13)  评论:(0)  加入收藏
本地装聊mysql数据库,真吃内存啊,微服务一起来,idea 开发工具就疯狂吃内存,前端一启动,node.js 就狂吃,网页再吃点,16g内存一会儿就崩了,如果再玩一下微信开发工具,估计都一点跑不起...【详细内容】
2022-10-23  小虎鲸宝妈记  今日头条  Tags:springcloud   点击:(12)  评论:(0)  加入收藏
站内最新
站内热门
站内头条