Spring boot

http://blog.csdn.net/z278718149/article/details/78866432


https://github.com/spring-projects/spring-boot/blob/v2.0.0.M7/spring-boot-project/spring-boot-dependencies/pom.xml

为了创建一个可执行的jar,这样可以在生产环境运行。可执行的jar包含已编译的classes和code 运行所需要的依赖。为了创建一个可执行的jar,需要在pom.xml文件中添加
spring-boot-maven-plugin 。所以只需要插入下面的依赖部分:

<build>
	<plugins>
		<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
		</plugin>
	</plugins>
</build>

如何使用Spring Boot
接下来将会涉及如何使用SpringBoot,包含了:build systems,auto-configutation,如何运行应用。同时也包含了一些SpringBoot最好的练习。

1>Build Systems
强烈建议选择一个build System 支持dependency management 并且可以push 到"Maven Central" 仓库。同时也建议选择Maven或者Gradle。这可能会使得SpringBoot 可以和Ant 一起build system
Spring Boot每一个版本都提供了一个它所支持的依赖集合,在练习是, 在build configuration时不需要为每一个依赖提供version,因为Spring boot会管理。当升级
Spring Boot 时,这些依赖也会升级到一直的版本。但是如果你需要也是可以指定版本号重写Spring boot推荐的。

为了配置工程可以从spring-boot-starter-parent继承来设置parent,如下:

<!-- Inherit defaults from Spring Boot -->
<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>2.0.0.M7</version>
</parent>

这个唯一一个需要知道Spring Boot 版本的。如果在引入其他的Starters,可以省去版本号。

Starters是一个方便的依赖集合可以用在应用中,可以获取一站式的用于所有的Spring和所需要相关的技术,不需要通过例子代码来查询。比如:如果想要使用Spring和JPA来访问DB,只需要项目中包括spring-boot-starter-data-jpa依赖即可。Starters包括很多依赖,这些依赖使得项目运行快速,并且有一致的,可迁移的依赖。

Spring Boot 应用Starters

Name	Description	Pom

spring-boot-starter
	

Core starter, including auto-configuration support, logging and YAML
	

Pom

spring-boot-starter-activemq
	

Starter for JMS messaging using Apache ActiveMQ
	

Pom

spring-boot-starter-amqp
	

Starter for using Spring AMQP and Rabbit MQ
	

Pom

spring-boot-starter-aop
	

Starter for aspect-oriented programming with Spring AOP and AspectJ
	

Pom

spring-boot-starter-artemis
	

Starter for JMS messaging using Apache Artemis
	

Pom

spring-boot-starter-batch
	

Starter for using Spring Batch
	

Pom

spring-boot-starter-cache
	

Starter for using Spring Framework’s caching support
	

Pom

spring-boot-starter-cloud-connectors
	

Starter for using Spring Cloud Connectors which simplifies connecting to services in cloud platforms like Cloud Foundry and Heroku
	

Pom

spring-boot-starter-data-cassandra
	

Starter for using Cassandra distributed database and Spring Data Cassandra
	

Pom

spring-boot-starter-data-cassandra-reactive
	

Starter for using Cassandra distributed database and Spring Data Cassandra Reactive
	

Pom

spring-boot-starter-data-couchbase
	

Starter for using Couchbase document-oriented database and Spring Data Couchbase
	

Pom

spring-boot-starter-data-couchbase-reactive
	

Starter for using Couchbase document-oriented database and Spring Data Couchbase Reactive
	

Pom

spring-boot-starter-data-elasticsearch
	

Starter for using Elasticsearch search and analytics engine and Spring Data Elasticsearch
	

Pom

spring-boot-starter-data-jpa
	

Starter for using Spring Data JPA with Hibernate
	

Pom

spring-boot-starter-data-ldap
	

Starter for using Spring Data LDAP
	

Pom

spring-boot-starter-data-mongodb
	

Starter for using MongoDB document-oriented database and Spring Data MongoDB
	

Pom

spring-boot-starter-data-mongodb-reactive
	

Starter for using MongoDB document-oriented database and Spring Data MongoDB Reactive
	

Pom

spring-boot-starter-data-neo4j
	

Starter for using Neo4j graph database and Spring Data Neo4j
	

Pom

spring-boot-starter-data-redis
	

Starter for using Redis key-value data store with Spring Data Redis and the Lettuce client
	

Pom

spring-boot-starter-data-redis-reactive
	

Starter for using Redis key-value data store with Spring Data Redis reactive and the Lettuce client
	

Pom

spring-boot-starter-data-rest
	

Starter for exposing Spring Data repositories over REST using Spring Data REST
	

Pom

spring-boot-starter-data-solr
	

Starter for using the Apache Solr search platform with Spring Data Solr
	

Pom

spring-boot-starter-freemarker
	

Starter for building MVC web applications using FreeMarker views
	

Pom

spring-boot-starter-groovy-templates
	

Starter for building MVC web applications using Groovy Templates views
	

Pom

spring-boot-starter-hateoas
	

Starter for building hypermedia-based RESTful web application with Spring MVC and Spring HATEOAS
	

Pom

spring-boot-starter-integration
	

Starter for using Spring Integration
	

Pom

spring-boot-starter-jdbc
	

Starter for using JDBC with the Tomcat JDBC connection pool
	

Pom

spring-boot-starter-jersey
	

Starter for building RESTful web applications using JAX-RS and Jersey. An alternative to spring-boot-starter-web
	

Pom

spring-boot-starter-jooq
	

Starter for using jOOQ to access SQL databases. An alternative to spring-boot-starter-data-jpa or spring-boot-starter-jdbc
	

Pom

spring-boot-starter-json
	

Starter for reading and writing json
	

Pom

spring-boot-starter-jta-atomikos
	

Starter for JTA transactions using Atomikos
	

Pom

spring-boot-starter-jta-bitronix
	

Starter for JTA transactions using Bitronix
	

Pom

spring-boot-starter-jta-narayana
	

Spring Boot Narayana JTA Starter
	

Pom

spring-boot-starter-mail
	

Starter for using Java Mail and Spring Framework’s email sending support
	

Pom

spring-boot-starter-mustache
	

Starter for building web applications using Mustache views
	

Pom

spring-boot-starter-quartz
	

Spring Boot Quartz Starter
	

Pom

spring-boot-starter-security
	

Starter for using Spring Security
	

Pom

spring-boot-starter-test
	

Starter for testing Spring Boot applications with libraries including JUnit, Hamcrest and Mockito
	

Pom

spring-boot-starter-thymeleaf
	

Starter for building MVC web applications using Thymeleaf views
	

Pom

spring-boot-starter-validation
	

Starter for using Java Bean Validation with Hibernate Validator
	

Pom

spring-boot-starter-web
	

Starter for building web, including RESTful, applications using Spring MVC. Uses Tomcat as the default embedded container
	

Pom

spring-boot-starter-web-services
	

Starter for using Spring Web Services
	

Pom

spring-boot-starter-webflux
	

Starter for building WebFlux applications using Spring Framework’s Reactive Web support
	

Pom

spring-boot-starter-websocket
	

Starter for building WebSocket applications using Spring Framework’s WebSocket support
	

Pom

Table 13.2. Spring Boot production starters
Name	Description	Pom

spring-boot-starter-actuator
	

Starter for using Spring Boot’s Actuator which provides production ready features to help you monitor and manage your application
	

Pom

Finally, Spring Boot also includes the following starters that can be used if you want to exclude or swap specific technical facets:

Table 13.3. Spring Boot technical starters
Name	Description	Pom

spring-boot-starter-jetty
	

Starter for using Jetty as the embedded servlet container. An alternative to spring-boot-starter-tomcat
	

Pom

spring-boot-starter-log4j2
	

Starter for using Log4j2 for logging. An alternative to spring-boot-starter-logging
	

Pom

spring-boot-starter-logging
	

Starter for logging using Logback. Default logging starter
	

Pom

spring-boot-starter-reactor-netty
	

Starter for using Reactor Netty as the embedded reactive HTTP server.
	

Pom

spring-boot-starter-tomcat
	

Starter for using Tomcat as the embedded servlet container. Default servlet container starter used by spring-boot-starter-web
	

Pom

spring-boot-starter-undertow
	

Starter for using Undertow as the embedded servlet container. An alternative to spring-boot-starter-tomcat
	

Pom


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值