SpringBoot四大神器之Starter
来源:互联网 发布:从其他excel导入数据 编辑:程序博客网 时间:2024/05/21 09:20
序
SpringBoot的starter主要用来简化依赖用的。本文主要分两部分,一部分是列出一些starter的依赖,另一部分是教你自己写一个starter。
部分starters的依赖
■ org.apache.logging.log4j:log4j-api
■ org.apache.logging.log4j:log4j-core
■ org.slf4j:jcl-over-slf4j
■ org.slf4j:jul-to-slf4jspring-boot-starter-logging■ ch.qos.logback:logback-classic
■ org.slf4j:jcl-over-slf4j
■ org.slf4j:jul-to-slf4j
■ org.slf4j:log4j-over-slf4jspring-boot-starter-mail■ org.springframework.boot:spring-boot-starter
■ org.springframework:spring-context
■ org.springframework:spring-context-support
■ com.sun.mail:javax.mailspring-boot-starter-mobile■ org.springframework.boot:spring-boot-starter
■ org.springframework.boot:spring-boot-starter-web
■ org.springframework.mobile:spring-mobile-devicespring-boot-starter-mustache■ org.springframework.boot:spring-boot-starter
■ org.springframework.boot:spring-boot-starter-web
■ com.samskivert:jmustachespring-boot-starter-redis■ org.springframework.boot:spring-boot-starter
■ org.springframework.data:spring-data-redis
■ redis.clients:jedisspring-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:groovyspring-boot-starter-security■ org.springframework.boot:spring-boot-starter
■ org.springframework:spring-aop
■org.springframework.security:spring-security-config
■org.springframework.security:spring-security-webspring-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-facebookspring-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-linkedinspring-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-twitterspring-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-testspring-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-dialectspring-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-websocketspring-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.elspring-boot-starter-validation■ org.springframework.boot:spring-boot-starter
■ org.apache.tomcat.embed:tomcat-embed-el
■org.hibernate:hibernate-validatorspring-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-supportspring-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-webmvcspring-boot-starter-websocket■ org.springframework.boot:spring-boot-starter
■ org.springframework.boot:spring-boot-starter-web
■ org.springframework:spring-messaging
■org.springframework:spring-websocketspring-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
# AutoConfigurationsorg.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
note
github工程源码
Spring Boot:定制自己的starter
Boot your own infrastructure – Extending Spring Boot in five steps
阅读全文
0 0
- SpringBoot四大神器之Starter
- SpringBoot四大神器之Starter
- SpringBoot四大神器之Actuator
- SpringBoot四大神器之Actuator
- SpringBoot四大神器之Actuator
- SpringBoot四大神器之Actuator
- SpringBoot四大神器之Actuator
- SpringBoot四大神器之Actuator
- SpringBoot四大神器之Actuator
- SpringBoot四大神器之Actuator
- SpringBoot四大神器之Actuator
- springboot之Starter POMs
- SpringBoot之starter(R)
- SpringBoot 之Spring Boot Starter依赖包及作用
- SpringBoot starter pom
- 集成springboot-starter-security
- Spring Boot有四大神器之actuator
- Spring Boot四大神器之Actuator
- QT下的base的加密
- Android-沉浸状态栏
- 基于echars的图像绘制
- 深入hibernate的三种状态
- 使用Nexus搭建Maven私服
- SpringBoot四大神器之Starter
- 大数据生态体系介绍
- Spring Dependencies and Depending on Spring
- Java知识点总结(五)
- 安卓自定义透明Dialog
- tp5时间戳功能的自定义实现。
- C#基础之RichTextBox
- Mac上基于Xcode 8.3.2, iOS 10.3(模拟器)搭建Appium 1.6.5 测试环境
- SDE For PostgreSQL物理迁移(冷备份,恢复)