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 关于三种工具说明: ...
随机推荐
- Codeforces Round #448 C. Square Subsets
题目链接 Codeforces Round #448 C. Square Subsets 题解 质因数 *质因数 = 平方数,问题转化成求异或方程组解的个数 求出答案就是\(2^{自由元-1}\) , ...
- POJ1222 EXTENDED LIGHTS OUT 高斯消元 XOR方程组
http://poj.org/problem?id=1222 在学校oj用搜索写了一次,这次写高斯消元,haoi现场裸xor方程消元没写出来,真实zz. #include<iostream> ...
- vijos p1768 数学
链接:点我 预处理:b[i][j]表示a[1] ... a[j]中比a[i]小的数的数量. 设 int get_lower_count(int b[], int l, int r) { return ...
- Spring Boot项目的Logback配置文件使用yaml格式
1.普通的Spring项目使用logback默认用properties文件做为配置变量. 2.如果非要用yaml文件,那么可以转成Spring Boot项目,天生无缝结合 3.没办法,如果项目配置文件 ...
- EBS安装完成后,对数据库相关配置的改动
EBS安装完成后,对数据库相关配置的改动 1.转为ASM,数据文件,控制文件,redo log,archived log从文件系统转移至ASM 2.禁用resource manager 由于发现系统的 ...
- 用最简单的例子理解复合模式(Composite Pattern)
在显示树形结构时,复合模式有很好的体现.本篇显示如下部门结构: 以上,有的节点包含子节点,有的节点部包含子节点.不管是什么节点,每个节点就代表一个部门. 首先设计一个关于部门的抽象基类. public ...
- Visual Studio中Debug和Release的区别
在Visual Studio中,生成应用程序的时候有2种模式:Debug和Release.两者之间如何取舍呢? 假设有这么简单的一段代码,在主程序中调用方法M1,M1方法调用M2方法,M2方法调用M3 ...
- 26复杂类型比较,使用Compare .NET objects组件
关于比较对象,在"06判等对象是否相等"中大致可以总结为: 关于比较方法: ● 实例方法Equals(object obj)既可以比较值类型,也可以比较引用类型 ● 静态方法E ...
- Gradle在Windows环境与Linux上配置有哪些不同?
我的开发环境:Windows + Android Studio + Gradle 2.8 all + Jenkins 公司CI 服务器环境: Linux + Gradle 2.10 bin + Jen ...
- freecms怎样在信息列表类标签中提取info.content
原文地址:http://javaz.cn/site/javaz/site_study/info/2015/22026.html 项目地址:http://www.freeteam.cn/ 因为info. ...