百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 技术教程 > 正文

初识SpringBoot Starter 初识不知曲中意,今闻已成曲中人

suiw9 2024-11-13 14:45 14 浏览 0 评论

什么是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-hornetq 通过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)。

相关推荐

5款Syslog集中系统日志常用工具对比推荐

一、为何要集中管理Syslog?Syslog由Linux/Unix系统及其他网络设备生成,广泛分布于整个网络。因其包含关键信息,可用于识别网络中的恶意活动,所以必须对其进行持续监控。将Sys...

跨平台、多数据库支持的开源数据库管理工具——DBeaver

简介今天给大家推荐一个开源的数据库管理工具——DBeaver。它支持多种数据库系统,包括Mysql、Oracle、PostgreSQL、SLQLite、SQLServer等。DBeaver的界面友好...

强烈推荐!数据库管理工具:Navicat Premium 16.3.2 (64位)

NavicatPremium,一款集数据迁移、数据库管理、SQL/查询编辑、智能设计、高效协作于一体的全能数据库开发工具。无论你是MySQL、MariaDB、MongoDB、SQLServer、O...

3 年 Java 程序员还玩不转 MongoDB,网友:失望

一、什么场景使用MongoDB?...

拯救MongoDB管理员的GUI工具大赏:从菜鸟到极客的生存指南

作为一名在NoSQL丛林中披荆斩棘的数据猎人,没有比GUI工具更称手的瑞士军刀了。本文将带你围观五款主流MongoDB管理神器的特性与暗坑,附赠精准到扎心的吐槽指南一、MongoDBCompass:...

mongodb/redis/neo4j 如何自己打造一个 web 数据库可视化客户端?

前言最近在做neo4j相关的同步处理,因为产线的可视化工具短暂不可用,发现写起来各种脚本非常麻烦。...

solidworks使用心得,纯干货!建议大家收藏

SolidWorks常见问题...

统一规约-关乎数字化的真正实现(规范统一性)

尽管数字化转型的浪潮如此深入人心,但是,对于OPCUA和TSN的了解却又甚少,这难免让人质疑其可实现性,因为,如果缺乏统一的语义互操作规范,以及更为具有广泛适用的网络与通信,则数字化实际上几乎难以具...

Elasticsearch节点角色配置详解(Node)

本篇文章将介绍如下内容:节点角色简介...

产前母婴用品分享 篇一:我的母婴购物清单及单品推荐

作者:DaisyH8746在张大妈上已经混迹很久了,有事没事看看“什么值得买”已渐渐成了一种生活习惯,然而却从来没有想过自己要写篇文章发布上来,直到由于我产前功课做得“太过认真”(认真到都有点过了,...

比任何人都光彩照人的假期!水润、紧致的肌肤护理程序

图片来源:谜尚愉快的假期临近了。身心振奋的休假季节。但是不能因为这种心情而失去珍贵的东西,那就是皮肤健康。炙热的阳光和强烈的紫外线是使我们皮肤老化的主犯。因此,如果怀着快乐的心情对皮肤置之不理,就会使...

Arm发布Armv9边缘AI计算平台,支持运行超10亿参数端侧AI模型

中关村在线2月27日消息,Arm正式发布Armv9边缘人工智能(AI)计算平台。据悉,该平台以全新的ArmCortex-A320CPU和领先的边缘AI加速器ArmEthos-U85NPU为核心...

柔性——面向大规模定制生产的数字化实现的基本特征

大规模定制生产模式的核心是柔性,尤其是体现在其对定制的要求方面。既然是定制,并且是大规模的定制,对于制造系统的柔性以及借助于数字化手段实现的柔性,就提出了更高的要求。面向大规模定制生产的数字化业务管控...

创建PLC内部标准——企业前进的道路

作者:FrankBurger...

标准化编程之 ----------- 西门子LPMLV30测试总结

PackML乃是由OMAC开发且被ISA所采用的自动化标准TR88.00.02,能够更为便捷地传输与检索一致的机器数据。PackML的主要宗旨在于于整个工厂车间倡导通用的“外观和感觉”,...

取消回复欢迎 发表评论: