天天看点

飞5的Spring Boot2(3)- 细说starters

飞5的Spring Boot2(3)- 细说starters

不使用Parent POM的方式​

不一定非需要从spring-boot-starter-parent进行继承,也可以单独在工程中使用,只需要在pom.xml中添加如下代码:

1<dependency>
2    <!-- Import dependency management from Spring Boot -->
3    <groupId>org.springframework.boot</groupId>
4    <artifactId>spring-boot-dependencies</artifactId>
5    <version>2.0.1.RELEASE</version>
6    <type>pom</type>
7    <scope>import</scope>
8</dependency>      

同样的,如果要升级Spring Data,就需要在项目中单独指定,代码如下:

1<!-- Override Spring Data release train provided by Spring Boot -->
 2<dependency>
 3    <groupId>org.springframework.data</groupId>
 4    <artifactId>spring-data-releasetrain</artifactId>
 5    <version>Fowler-SR2</version>
 6    <type>pom</type>
 7    <scope>import</scope>
 8</dependency>
 9<dependency>
10    <groupId>org.springframework.boot</groupId>
11    <artifactId>spring-boot-dependencies</artifactId>
12    <version>2.0.1.RELEASE</version>
13    <type>pom</type>
14    <scope>import</scope>
15</dependency>      

使用parent方式

说到了不使用parent的方式,添加如下代码:

1<!-- Inherit defaults from Spring Boot -->
2<parent>
3    <groupId>org.springframework.boot</groupId>
4    <artifactId>spring-boot-starter-parent</artifactId>
5    <version>2.0.1.RELEASE</version>
6</parent>      

如果想加入Spring Data,需要在配置文件中指定版本,代码如下:

1<properties>
2    <spring-data-releasetrain.version>Fowler-SR2</spring-data-releasetrain.version>
3</properties>      

starters

官方都遵循类似的命名模式;spring-boot-starter-*,其中 *是特定类型的应用程序。

org.springframework.boot提供的starters包括:

名称 描述
spring-boot-starter 核心配置,包括自动配置、日志记录等
spring-boot-starter-activemq 使用Apache ActiveMQ进行JMS消息传递
spring-boot-starter-amqp 使用amqp或者Rabbit MQ
spring-boot-starter-aop 进行面向切面编程依赖
spring-boot-starter-artemis 使用Apache Artemis开始的JMS消息传递
spring-boot-starter-batch 使用Spring Batch的依赖
spring-boot-starter-cache 使用Spring的缓存依赖
spring-boot-starter-cloud-connectors 使用Spring Cloud Connectors,可简化Cloud Foundry和Heroku等云平台中的服务连接
spring-boot-starter-data-cassandra Spring Data Cassandra的依赖
spring-boot-starter-data-cassandra-reactive 使用Cassandra分布式数据库和Spring Data Cassandra Reactive的依赖
spring-boot-starter-data-couchbase Couchbase的依赖
spring-boot-starter-data-couchbase-reactive 使用Couchbase面向文档的数据库和Spring Data Couchbase Reactive的依赖
spring-boot-starter-data-elasticsearch Spring Data Elasticsearch的依赖
spring-boot-starter-data-jpa 使用JPA,默认使用hibernate
spring-boot-starter-data-ldap Spring Data LDAP依赖
spring-boot-starter-data-mongodb MongoDB依赖
spring-boot-starter-data-mongodb-reactive mongodb和mongodb reactive
spring-boot-starter-data-neo4j Spring Data Neo4j依赖
spring-boot-starter-data-redis redis依赖
spring-boot-starter-data-rest Spring Data REST公开库
spring-boot-starter-data-solr solr依赖
spring-boot-starter-freemarker freemarker依赖
spring-boot-starter-groovy-templates 使用Groovy模板视图构建MVC Web应用程序
spring-boot-starter-integration spring integration依赖
spring-boot-starter-jdbc 使用JDBC和HikariCP连接池
spring-boot-starter-jersey jersey restful依赖
spring-boot-starter-jooq jooq依赖
spring-boot-starter-json 读写json依赖
spring-boot-starter-mail 邮件支持
spring-boot-starter-mustache 模板mustache依赖
spring-boot-starter-quartz 调度任务依赖
spring-boot-starter-security 安全依赖
spring-boot-starter-test 测试依赖
spring-boot-starter-thymeleaf thymeleaf依赖
spring-boot-starter-validation 验证依赖
spring-boot-starter-web web应用和spring mvc依赖
spring-boot-starter-web-services webservice依赖
spring-boot-starter-webflux webflux依赖
spring-boot-starter-websocket

继续阅读