SpringBoot四大神器之Starter
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的更多相关文章
- SpringBoot四大神器之auto-configuration
SpringBoot 自动配置主要通过 @EnableAutoConfiguration, @Conditional, @EnableConfigurationProperties 或者 @Confi ...
- SpringBoot四大神器之Actuator
介绍 Spring Boot有四大神器,分别是auto-configuration.starters.cli.actuator,本文主要讲actuator.actuator是spring boot提供 ...
- Springboot监控之一:SpringBoot四大神器之Actuator
介绍 Spring Boot有四大神器,分别是auto-configuration.starters.cli.actuator,本文主要讲actuator.actuator是spring boot提供 ...
- Springboot监控之一:SpringBoot四大神器之Actuator之3-springBoot的监控和管理--指标说明
Spring Boot包含很多其他的特性,它们可以帮你监控和管理发布到生产环境的应用.你可以选择使用HTTP端点,JMX或远程shell(SSH或Telnet)来管理和监控应用.审计(Auditing ...
- Spring Boot]SpringBoot四大神器之Actuator
论文转载自博客: https://blog.csdn.net/Dreamhai/article/details/81077903 https://bigjar.github.io/2018/08/19 ...
- Springboot监控之一:SpringBoot四大神器之Actuator之2--覆盖修改spring cloud的默认的consul健康检查规则
微服务网关是socket长连接与支付公司对接,该网关需要提供http接口给内部系统调用,当socket没有建立连接时(网关服务的高可用是haProxy搭建的,有些服务的socket可能未连上支付公司) ...
- Springboot监控之一:SpringBoot四大神器之Actuator之2--springboot健康检查
Health 信息是从 ApplicationContext 中所有的 HealthIndicator 的 Bean 中收集的, Spring Boot 内置了一些 HealthIndicator. ...
- Springboot监控之一:SpringBoot四大神器之Actuator之2--spring boot健康检查对Redis的连接检查的调整
因为项目里面用到了redis集群,但并不是用spring boot的配置方式,启动后项目健康检查老是检查redis的时候状态为down,导致注册到eureka后项目状态也是down.问下能不能设置sp ...
- ORACLE恢复神器之ODU/AUL/DUL
分享ORACLE数据库恢复神器之ODU.DUL和AUL工具. ODU:ORACLE DATABASE UNLOADER DUL:DATA UNLOADER AUL:也称MyDUL 关于三种工具说明: ...
随机推荐
- python语法(一)
Python是一种面向对象.直译式电脑编程语言,也是一种功能强大的通用型语言,已经具有近二十年的发展历史,成熟且稳定.在近几年,大数据,人工智能火起来之后也是水涨船高,被越来越多的人知道,并且越来越多 ...
- [BZOJ5306][HAOI2018]染色(容斥+FFT)
https://www.cnblogs.com/zhoushuyu/p/9138251.html 注意如果一开始F(i)中内层式子中j枚举的是除前i种颜色之外还有几种出现S次的颜色,那么后面式子就会难 ...
- 【字符串哈希】The 16th UESTC Programming Contest Preliminary F - Zero One Problem
题意:给你一个零一矩阵,q次询问,每次给你两个长宽相同的子矩阵,问你它们是恰好有一位不同,还是完全相同,还是有多于一位不同. 对每行分别哈希,先一行一行地尝试匹配,如果恰好发现有一行无法对应,再对那一 ...
- Git 历险记
Git历险记(一) 作为分布式版本控制系统的重要代表--Git已经为越来越多的人所认识,它相对于我们熟悉的CVS.SVN甚至同时分布式控制系统的Mercurial,有哪些优势和不足呢.这次InfoQ中 ...
- HAproxy和TIME WAIT的一次问题排查
近日平稳运行了将近4年的发号器突然出现问题,在元旦0分的时候出现短暂的性能下降,导致发号失败率飙高到一个不可接收的值,哎,意外总是发生在你想不到的地方. 这几天赶紧和小伙伴们赶紧追查原因,制定改造方案 ...
- JavaScript RegExp对象的exec()方法
JavaScript RegExp对象的exec()方法用来匹配字符串,它的行为与match()有些不同. 对于RegExpObject.exec(),w3school上面是这样介绍的: exec() ...
- 关于ANDROID模拟器的一些事
转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! 继上一篇Android Studio VS Eclipse的文章后接着来分享AnDevCo ...
- KJBitmap使用方法
摘要 本文原创,转载请注明地址:http://kymjs.com/code/2015/03/25/01 摘要 好像最近一个月都没有写博客了,正好伴着KJFrameForAndroid 更新v2.14版 ...
- 5.跟我学solr---QueryResponseWriter具体解释
简单介绍 QueryResponseWriter是solr的一个插件,与上一章讲的SolrRequestHandler是配对的,用于定义solr查询结果的返回格式. 回到solr admin的查询页面 ...
- Android平台上优秀的开源项目
软件名:gaeproxy 软件作用:Android手机配置GoAgent. 项目地址:https://github.com/madeye/gaeproxy.git 软件名:ProxyDroid 软件作 ...