摘要:序的主要用来简化依赖用的。本文主要分两部分,一部分是列出一些的依赖,另一部分是教你自己写一个。
序
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 |
来自<
1、选择已有的starters,在此基础上进行扩展.
2、创建自动配置文件并设定META-INF/spring.factories里的内容.
3、发布你的starter
添加依赖管理添加starter自己的依赖org.springframework.boot spring-boot-dependencies ${spring.boot.version} pom import
新建configurationorg.springframework.boot spring-boot-starter org.springframework.boot spring-boot-starter-web
@Configuration @ComponentScan( basePackages = {"com.codecraft.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.codecraft.actuator.configuration.WebAutoConfiguration发布
mvn clean install引用
启动访问com.codecraft spring-boot-starter-actuator-web 1.0-SNAPSHOT
mvn spring-boot:run
访问
http://localhost:8080/navnote
Spring Boot:定制自己的starter
Boot your own infrastructure – Extending Spring Boot in five steps
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/65371.html
...。 可能你有很多理由不放弃SSM,SSH,但是当你一旦使用了springboot ,你会觉得一切变得简单了,配置变的简单了、编码变的简单了,部署变的简单了,感觉自己健步如飞,开发速度大大提高了。就好比,当你用了IDEA,你会觉得再也...
...figurationPropertiesAutoConfiguration, 里面的类都是自动配置类,SpringBoot会根据这些自动配置类去自动配置环境。 下面我们就自动动手写一个starter。 二、自定义Starter 首先先介绍几个条件注解。 @ConditionalOnBean:当容器里有指定的Bean为...
...结自己学习的东西,现在终于有点时间了,所将整理一套SpringBoot kotlin 的开发教程,希望能够帮组更多想从Java转Kotlin的朋友。 一、Kotlin简介 Kotlin是一门静态语言,支持多种平台,包括移动端、服务端以及浏览器端,此外,Kotlin...
...己的业务功能。Eureka这个组件是不能单独运行的,需要以Springboot作为应用载体,真正的部署到虚机上面才能运行。 二、创建Eureka注册中心 注册中心,顾名思义,类似于zookeeper一样,提供服务注册发现功能,即服务端的服务地址...
(why)为什么springboot火遍全世界 springboot 有个好爹spring springboot 遗传了爹的优秀基因而生 大神们都在讲服务化(service),springboot做服务化再合适不过了 springboot入门简单(PS:国内使用thinkphp也是一个道理,快速构建,快速发布) and so...
阅读 2610·2021-11-25 09:43
阅读 2804·2021-11-25 09:43
阅读 1094·2021-11-24 11:15
阅读 2011·2021-11-22 15:25
阅读 3151·2021-11-11 16:55
阅读 2743·2021-11-04 16:10
阅读 2743·2021-09-29 09:32
阅读 2469·2021-09-14 18:02