SpringBoot的starter主要用来简化依赖用的。本文主要分两部分,一部分是列出一些starter的依赖,另一部分是教你自己写一个starter。

部分starters的依赖

Starter(Group ID: org.springframework.boot) 传递依赖于
spring-boot-starter-log4j2 ■ org.apache.logging.log4j:log4j-slf4j-impl
■ org.apache.logging.log4j:log4j-api
■ org.apache.logging.log4j:log4j-core
■ org.slf4j:jcl-over-slf4j
■ org.slf4j:jul-to-slf4j
spring-boot-starter-logging ■ ch.qos.logback:logback-classic
■ org.slf4j:jcl-over-slf4j
■ org.slf4j:jul-to-slf4j
■ org.slf4j:log4j-over-slf4j
spring-boot-starter-mail ■ org.springframework.boot:spring-boot-starter
■ org.springframework:spring-context
■ org.springframework:spring-context-support
■ com.sun.mail:javax.mail
spring-boot-starter-mobile ■ org.springframework.boot:spring-boot-starter
■ org.springframework.boot:spring-boot-starter-web
■ org.springframework.mobile:spring-mobile-device
spring-boot-starter-mustache ■ org.springframework.boot:spring-boot-starter
■ org.springframework.boot:spring-boot-starter-web
■ com.samskivert:jmustache
spring-boot-starter-redis ■ org.springframework.boot:spring-boot-starter
■ org.springframework.data:spring-data-redis
■ redis.clients:jedis
spring-boot-starter-remote-shell ■ org.springframework.boot:spring-boot-starter
■ org.springframework.boot:spring-boot-starter-actuator
■ org.crashub:crash.cli
■ org.crashub:crash.connectors.ssh (excludes org.codehaus.groovy:groovy-all)
■ org.crashub:crash.connectors.telnet (excludes javax.servlet:servlet-api, log4j :log4j, commons-logging:commons-logging)
■ org.crashub:crash.embed.spring(excludes org.springframework:spring-web, org.codehaus.groovy:groovy-all)
■ org.crashub:crash.plugins.cron (excludes org.codehaus.groovy:groovy-all)
■ org.crashub:crash.plugins.mail (excludes org.codehaus.groovy:groovy-all)
■ org.crashub:crash.shell (excludes org.codehaus.groovy:groovy-all)
■ org.codehaus.groovy:groovy
spring-boot-starter-security ■ org.springframework.boot:spring-boot-starter
■ org.springframework:spring-aop
■org.springframework.security:spring-security-config
■org.springframework.security:spring-security-web
spring-boot-starter-social-facebook ■org.springframework.boot:spring-boot-starter
■ org.springframework.boot:spring-boot-starter-web
■org.springframework.social:spring-social-config
■ org.springframework.social:spring-social-core
■ org.springframework.social:spring-social-web
■org.springframework.social:spring-social-facebook
spring-boot-starter-social-linkedin ■org.springframework.boot:spring-boot-starter
■ org.springframework.boot:spring-boot-starter-web
■org.springframework.social:spring-social-config
■ org.springframework.social:spring-social-core
■ org.springframework.social:spring-social-web
■org.springframework.social:spring-social-linkedin
spring-boot-starter-social-twitter ■org.springframework.boot:spring-boot-starter
■ org.springframework.boot:spring-boot-starter-web
■ org.springframework.social:spring-social-config
■ org.springframework.social:spring-social-core
■org.springframework.social:spring-social-web
■ org.springframework.social:spring-social-twitter
spring-boot-starter-test ■ junit:junit
■ org.mockito:mockito-core
■ org.hamcrest:hamcrest-core
■ org.hamcrest:hamcrest-library
■ org.springframework:spring-core(excludes commons-logging:commons-logging)
■ org.springframework:spring-test
spring-boot-starter-thymeleaf ■ org.springframework.boot:spring-boot-starter
■ org.springframework.boot:spring-boot-starter-web
■ org.thymeleaf:thymeleaf-spring4
■nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect
spring-boot-starter-tomcat ■ org.apache.tomcat.embed:tomcat-embed-core
■ org.apache.tomcat.embed:tomcat-embed-el
■org.apache.tomcat.embed:tomcat-embed-logging-juli
■org.apache.tomcat.embed:tomcat-embed-websocket
spring-boot-starter-undertow ■ io.undertow:undertow-core
■ io.undertow:undertow-servlet(excludes org.jboss.spec.javax.servlet:jboss-servlet-api_3.1_spec)
■ io.undertow:undertow-websockets-jsr
■ javax.servlet:javax.servlet-api
■ org.glassfish:javax.el
spring-boot-starter-validation ■ org.springframework.boot:spring-boot-starter
■ org.apache.tomcat.embed:tomcat-embed-el
■org.hibernate:hibernate-validator
spring-boot-starter-velocity ■ org.springframework.boot:spring-boot-starter
■ org.springframework.boot:spring-boot-starter-web
■ commons-beanutils:commons-beanutils
■ commons-collections:commons-collections
■ commons-digester:commons-digester
■ org.apache.velocity:velocity
■ org.apache.velocity:velocity-tools
■ org.springframework:spring-context-support
spring-boot-starter-web ■ org.springframework.boot:spring-boot-starter
■ org.springframework.boot:spring-boot-starter-tomcat
■ org.springframework.boot:spring-boot-starter-validation
■com.fasterxml.jackson.core:jackson-databind
■ org.springframework:spring-web
■ org.springframework:spring-webmvc
spring-boot-starter-websocket ■ org.springframework.boot:spring-boot-starter
■ org.springframework.boot:spring-boot-starter-web
■ org.springframework:spring-messaging
■org.springframework:spring-websocket
spring-boot-starter-ws ■ org.springframework.boot:spring-boot-starter
■ org.springframework.boot:spring-boot-starter-web ■org.springframework:spring-jms
■ org.springframework:spring-oxm
■ org.springframework.ws:spring-ws-core
■ org.springframework.ws:spring-ws-support

Reference

来自<<Spring Boot in Action>>的附录B SpringBoot Starters的内容

如何自己写starter

主要步骤

  • 1、选择已有的starters,在此基础上进行扩展.

  • 2、创建自动配置文件并设定META-INF/spring.factories里的内容.

  • 3、发布你的starter

添加依赖管理

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

添加starter自己的依赖

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

新建configuration

@Configuration
@ComponentScan( basePackages = {"com.patterncat.actuator"} )
public class WebAutoConfiguration { /**
* addViewController方法不支持placeholder的解析
* 故在这里用变量解析出来
*/
@Value("${actuator.web.base:}")
String actuatorBase; // @Bean
// public ActuatorNavController actuatorNavController(){
// return new ActuatorNavController();
// } @Bean
public WebMvcConfigurerAdapter configStaticMapping() {
return new WebMvcConfigurerAdapter() {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
//配置跳转
registry.addViewController(actuatorBase+"/nav").setViewName(
"forward:/static/nav.html");
} @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/**").
addResourceLocations("classpath:/static/");
}
};
} }

修改/META-INF/spring.factories

# AutoConfigurations
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.patterncat.actuator.configuration.WebAutoConfiguration

发布

mvn clean install

引用

        <dependency>
<groupId>com.patterncat</groupId>
<artifactId>spring-boot-starter-actuator-web</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>

启动访问

mvn spring-boot:run

访问

 
http://localhost:8080/nav

												

SpringBoot四大神器之Starter的更多相关文章

  1. SpringBoot四大神器之auto-configuration

    SpringBoot 自动配置主要通过 @EnableAutoConfiguration, @Conditional, @EnableConfigurationProperties 或者 @Confi ...

  2. SpringBoot四大神器之Actuator

    介绍 Spring Boot有四大神器,分别是auto-configuration.starters.cli.actuator,本文主要讲actuator.actuator是spring boot提供 ...

  3. Springboot监控之一:SpringBoot四大神器之Actuator

    介绍 Spring Boot有四大神器,分别是auto-configuration.starters.cli.actuator,本文主要讲actuator.actuator是spring boot提供 ...

  4. Springboot监控之一:SpringBoot四大神器之Actuator之3-springBoot的监控和管理--指标说明

    Spring Boot包含很多其他的特性,它们可以帮你监控和管理发布到生产环境的应用.你可以选择使用HTTP端点,JMX或远程shell(SSH或Telnet)来管理和监控应用.审计(Auditing ...

  5. Spring Boot]SpringBoot四大神器之Actuator

    论文转载自博客: https://blog.csdn.net/Dreamhai/article/details/81077903 https://bigjar.github.io/2018/08/19 ...

  6. Springboot监控之一:SpringBoot四大神器之Actuator之2--覆盖修改spring cloud的默认的consul健康检查规则

    微服务网关是socket长连接与支付公司对接,该网关需要提供http接口给内部系统调用,当socket没有建立连接时(网关服务的高可用是haProxy搭建的,有些服务的socket可能未连上支付公司) ...

  7. Springboot监控之一:SpringBoot四大神器之Actuator之2--springboot健康检查

    Health 信息是从 ApplicationContext 中所有的 HealthIndicator 的 Bean 中收集的, Spring Boot 内置了一些 HealthIndicator. ...

  8. Springboot监控之一:SpringBoot四大神器之Actuator之2--spring boot健康检查对Redis的连接检查的调整

    因为项目里面用到了redis集群,但并不是用spring boot的配置方式,启动后项目健康检查老是检查redis的时候状态为down,导致注册到eureka后项目状态也是down.问下能不能设置sp ...

  9. ORACLE恢复神器之ODU/AUL/DUL

    分享ORACLE数据库恢复神器之ODU.DUL和AUL工具. ODU:ORACLE DATABASE UNLOADER DUL:DATA UNLOADER AUL:也称MyDUL 关于三种工具说明: ...

随机推荐

  1. Centos 安装 Wireshark

    Wireshark是一款数据包识别软件,应用很广泛. yum install wireshark yum install wireshark-gnome

  2. NOIP差不多可以退役的退役记录

    好吧,现在既然苟回来了,就来回忆一下我NOIP2017的黑历史吧. Day-1: 原本以为是很平静的一天,上午学考机房强行断网,原因是腾出网速给对面学考的同学们查资料用.好吧没法刷题我只能选择颓废…… ...

  3. python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐(二)

    在上一篇blog:python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐 中介绍了python中的tkinter的一些东西,你可能对tkinter有一定的了解了.这篇b ...

  4. HDU 5683 zxa and xor 暴力模拟

    zxa and xor 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5683 Description zxa had a great interes ...

  5. Alpha冲刺(1/10)——追光的人

    1.队友信息 队员学号 队员博客 221600219 小墨 https://www.cnblogs.com/hengyumo/ 221600240 真·大能猫 https://www.cnblogs. ...

  6. Qt 4.7.2移植到ARM教程

    Qt的移植包括步骤如下: 1.下载并安装VMware WorkStation 12(最好比较高级的版本,早期的版本共享目录在虚拟机里可能显 示不了). 2.下载ubuntu 14.0.4(最好是lts ...

  7. mongoDB系列之(三):mongoDB 分片

    1. monogDB的分片(Sharding) 分片是mongoDB针对TB级别以上的数据量,采用的一种数据存储方式. mongoDB采用将集合进行拆分,然后将拆分的数据均摊到几个mongoDB实例上 ...

  8. spring---transaction(5)---事务的体系

    1.写在前面 事务的模型为3中: 本地事务模式. 编程事务模式. 声明事务模式. 例子1:本地事务模式 Connection conn=jdbcDao.getConnection(); Prepare ...

  9. HDU 4717 The Moving Points (三分)

    The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  10. 编译Opencv的GPU,利用CUDA加速

    首先检查自己的机器是否支持,否则都是白搭(仅仅有NVIDIA的显卡才支持.可在设备管理器中查看) 假设不用GPU.能够直接官网下载预编译好的库 环境: 1 VS2013 2 Opencv2.4.9 3 ...