多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# 13.5. Starters ### 13.5. Starters Starters是一个依赖描述符的集合,你可以将它包含进项目中,这样添加依赖就非常方便。你可以获取所有Spring及相关技术的一站式服务,而不需要翻阅示例代码,拷贝粘贴大量的依赖描述符。例如,如果你想使用Spring和JPA进行数据库访问,只需要在项目中包含`spring-boot-starter-data-jpa`依赖,然后你就可以开始了。 该starters包含很多搭建,快速运行项目所需的依赖,并提供一致的,可管理传递性的依赖集。 **名字有什么含义**:所有官方starters遵循相似的命名模式:`spring-boot-starter-*`,在这里`*`是一种特殊的应用程序类型。该命名结构旨在帮你找到需要的starter。很多集成于IDEs中的Maven插件允许你通过名称name搜索依赖。例如,使用相应的Eclipse或STS插件,你可以简单地在POM编辑器中点击`ctrl-space`,然后输入"spring-boot-starter"就可以获取一个完整列表。正如[Creating your own starter](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-custom-starter)章节中讨论的,第三方starters不应该以`spring-boot`开头,因为它跟Spring Boot官方artifacts冲突。一个acme的第三方starter通常命名为`acme-spring-boot-starter`。 以下应用程序starters是Spring Boot在`org.springframework.boot` group下提供的: **表 13.1. Spring Boot application starters** 名称描述Pomspring-boot-starter-test用于测试Spring Boot应用,支持常用测试类库,包括JUnit, Hamcrest和Mockito[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-test/pom.xml)spring-boot-starter-mobile用于使用Spring Mobile开发web应用[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-mobile/pom.xml)spring-boot-starter-social-twitter对使用Spring Social Twitter的支持[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-social-twitter/pom.xml)spring-boot-starter-cache用于使用Spring框架的缓存支持[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-cache/pom.xml)spring-boot-starter-activemq用于使用Apache ActiveMQ实现JMS消息[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-activemq/pom.xml)spring-boot-starter-jta-atomikos用于使用Atomikos实现JTA事务[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-jta-atomikos/pom.xml)spring-boot-starter-aop用于使用Spring AOP和AspectJ实现面向切面编程[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-aop/pom.xml)spring-boot-starter-web用于使用Spring MVC构建web应用,包括RESTful。Tomcat是默认的内嵌容器[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-web/pom.xml)spring-boot-starter-data-elasticsearch用于使用Elasticsearch搜索,分析引擎和Spring Data Elasticsearch[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-data-elasticsearch/pom.xml)spring-boot-starter-jdbc对JDBC的支持(使用Tomcat JDBC连接池)[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-jdbc/pom.xml)spring-boot-starter-batch对Spring Batch的支持[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-batch/pom.xml)spring-boot-starter-social-facebook用于使用Spring Social Facebook[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-social-facebook/pom.xml)spring-boot-starter-web-services对Spring Web服务的支持[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-web-services/pom.xml)spring-boot-starter-jta-narayanaSpring Boot Narayana JTA Starter[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-jta-narayana/pom.xml)spring-boot-starter-thymeleaf用于使用Thymeleaf模板引擎构建MVC web应用[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-thymeleaf/pom.xml)spring-boot-starter-mail用于使用Java Mail和Spring框架email发送支持[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-mail/pom.xml)spring-boot-starter-jta-bitronix用于使用Bitronix实现JTA事务[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-jta-bitronix/pom.xml)spring-boot-starter-data-mongodb用于使用基于文档的数据库MongoDB和Spring Data MongoDB[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-data-mongodb/pom.xml)spring-boot-starter-validation用于使用Hibernate Validator实现Java Bean校验[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-validation/pom.xml)spring-boot-starter-jooq用于使用JOOQ访问SQL数据库,可使用[spring-boot-starter-data-jpa](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#spring-boot-starter-data-jpa)或[spring-boot-starter-jdbc](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#spring-boot-starter-jdbc)替代[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-jooq/pom.xml)spring-boot-starter-redis用于使用Spring Data Redis和Jedis客户端操作键-值存储的Redis,在1.4中已被[spring-boot-starter-data-redis](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#spring-boot-starter-data-redis)取代[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-redis/pom.xml)spring-boot-starter-data-cassandra用于使用分布式数据库Cassandra和Spring Data Cassandra[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-data-cassandra/pom.xml)spring-boot-starter-hateoas用于使用Spring MVC和Spring HATEOAS实现基于超媒体的RESTful web应用[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-hateoas/pom.xml)spring-boot-starter-integration用于使用Spring Integration[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-integration/pom.xml)spring-boot-starter-data-solr通过Spring Data Solr使用Apache Solr搜索平台[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-data-solr/pom.xml)spring-boot-starter-freemarker用于使用FreeMarker模板引擎构建MVC web应用[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-freemarker/pom.xml)spring-boot-starter-jersey用于使用JAX-RS和Jersey构建RESTful web应用,可使用[spring-boot-starter-web](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#spring-boot-starter-web)替代[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-jersey/pom.xml)spring-boot-starter核心starter,包括自动配置支持,日志和YAML[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter/pom.xml)spring-boot-starter-data-couchbase用于使用基于文档的数据库Couchbase和Spring Data Couchbase[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-data-couchbase/pom.xml)spring-boot-starter-artemis使用Apache Artemis实现JMS消息[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-artemis/pom.xml)spring-boot-starter-cloud-connectors对Spring Cloud Connectors的支持,用于简化云平台下(例如Cloud Foundry 和Heroku)服务的连接[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-cloud-connectors/pom.xml)spring-boot-starter-social-linkedin用于使用Spring Social LinkedIn[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-social-linkedin/pom.xml)spring-boot-starter-velocity用于使用Velocity模板引擎构建MVC web应用,**从1.4版本过期**[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-velocity/pom.xml)spring-boot-starter-data-rest用于使用Spring Data REST暴露基于REST的Spring Data仓库[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-data-rest/pom.xml)spring-boot-starter-data-gemfire用于使用分布式数据存储GemFire和Spring Data GemFire[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-data-gemfire/pom.xml)spring-boot-starter-groovy-templates用于使用Groovy模板引擎构建MVC web应用[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-groovy-templates/pom.xml)spring-boot-starter-amqp用于使用Spring AMQP和Rabbit MQ[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-amqp/pom.xml)spring-boot-starter-hornetq用于使用HornetQ实现JMS消息,被[spring-boot-starter-artemis](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#spring-boot-starter-artemis)取代[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-hornetq/pom.xml)spring-boot-starter-ws用于使用Spring Web服务,被[spring-boot-starter-web-services](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#spring-boot-starter-web-services)取代[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-ws/pom.xml)spring-boot-starter-security对Spring Security的支持[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-security/pom.xml)spring-boot-starter-data-redis用于使用Spring Data Redis和Jedis客户端操作键—值数据存储Redis[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-data-redis/pom.xml)spring-boot-starter-websocket用于使用Spring框架的WebSocket支持构建WebSocket应用[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-websocket/pom.xml)spring-boot-starter-mustache用于使用Mustache模板引擎构建MVC web应用[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-mustache/pom.xml)spring-boot-starter-data-neo4j用于使用图数据库Neo4j和Spring Data Neo4j[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-data-neo4j/pom.xml)spring-boot-starter-data-jpa用于使用Hibernate实现Spring Data JPA[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-data-jpa/pom.xml)除了应用程序starters,以下starters可用于添加[production ready](../V.%20Spring%20Boot%20Actuator/README.md)的功能: **表 13.2. Spring Boot生产级starters** 名称描述Pomspring-boot-starter-actuator用于使用Spring Boot的Actuator,它提供了production ready功能来帮助你监控和管理应用程序[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-actuator/pom.xml)spring-boot-starter-remote-shell用于通过SSH,使用CRaSH远程shell监控,管理你的应用[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-remote-shell/pom.xml)最后,Spring Boot还包含一些用于排除或交换某些特定技术方面的starters: **表 13.3. Spring Boot技术性starters** 名称描述Pomspring-boot-starter-undertow用于使用Undertow作为内嵌servlet容器,可使用[spring-boot-starter-tomcat](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#spring-boot-starter-tomcat)替代[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-undertow/pom.xml)spring-boot-starter-logging用于使用Logback记录日志,默认的日志starter[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-logging/pom.xml)spring-boot-starter-tomcat用于使用Tomcat作为内嵌servlet容器,[spring-boot-starter-web](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#spring-boot-starter-web)使用的默认servlet容器[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-tomcat/pom.xml)spring-boot-starter-jetty用于使用Jetty作为内嵌servlet容器,可使用[spring-boot-starter-tomcat](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#spring-boot-starter-tomcat)替代[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-jetty/pom.xml)spring-boot-starter-log4j2用于使用Log4j2记录日志,可使用[spring-boot-starter-logging](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#spring-boot-starter-logging)代替[Pom](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/spring-boot-starter-log4j2/pom.xml)**注**:查看GitHub上位于`spring-boot-starters`模块内的[README文件](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters/README.adoc),可以获取到一个社区贡献的其他starters列表。