无论在构建项目时使用的是Maven、Gradle还是Spring Boot CLI,Spring Boot都为Spring应用程序常用的很多库提供了依赖管理支持功能。表D-1列出了Spring Boot 1.3.0版本支持的所有库依赖。
在很多情况下,这些依赖都会通过某个Spring Boot起步依赖自动添加到项目和Classpath里(如附录A所述)。但是,如果你正在使用的起步依赖没有覆盖到某个库,而你需要使用这个库,那就得在Maven或Gradle的构建说明里显式地声明这个依赖。
举例来说,如果你的项目需要引入H2嵌入式数据库,那么你需要在Gradle里加入如下声明:
compile("com.h2database:h2")
在Maven里可以添加类似的声明:
<dependency> <groupId>com.h2database</groupId> <version>h2</version></dependency>
请注意,在这两种情况下,都不需要指定版本号,Spring Boot的依赖管理会替你处理这个问题的。但是,如果想覆盖Spring Boot选择的版本,你也可以显式地提供一个版本号。
如果在使用Spring Boot CLI运行应用程序,你可以在Groovy里像这样使用@Grab
注解:
@Grab("h2")
在使用@Grab
注解引入表D-1里的库时,你只需要指定Artifact ID就可以了。Spring Boot扩展了@Grab
,让它可以推测出Group ID和版本号。
表D-1 Spring Boot 1.3.0所支持的库依赖
Group ID
Artifact ID
版本号
antlr
antlr
2.7.7
ch.qos.logback
logback-access
1.1.3
ch.qos.logback
logback-classic
1.1.3
com.atomikos
transactions-jdbc
3.9.3
com.atomikos
transactions-jms
3.9.3
com.atomikos
transactions-jta
3.9.3
com.fasterxml.
jackson.core
jackson-annotations
2.6.3
com.fasterxml.
jackson.core
jackson-core
2.6.3
com.fasterxml.
jackson.core
jackson-databind
2.6.3
com.fasterxml.
jackson.dataformat
jackson-dataformat-
csv
2.6.3
com.fasterxml.
jackson.dataformat
jackson-dataformat-
xml
2.6.3
com.fasterxml.
jackson.dataformat
jackson-dataformat-
yaml
2.6.3
com.fasterxml.
jackson.datatype
jackson-datatype-
hibernate4
2.6.3
com.fasterxml.
jackson.datatype
jackson-datatype-
hibernate5
2.6.3
com.fasterxml.
jackson.datatype
jackson-datatype-
jdk7
2.6.3
com.fasterxml.
jackson.datatype
jackson-datatype-
jdk8
2.6.3
com.fasterxml.
jackson.datatype
jackson-datatype-
joda
2.6.3
com.fasterxml.
jackson.datatype
jackson-datatype-
jsr310
2.6.3
com.fasterxml.
jackson.module
jackson-module-
parameter-names
2.6.3
com.gemstone.
gemfire
gemfire
8.1.0
com.github.mxab.
thymeleaf.extras
thymeleaf-extras-
data-attribute
1.3
com.google.
code.gson
gson
2.3.1
com.googlecode.
json
simple-json-simple
1.1.1
com.h2database
h2
1.4.190
com.hazelcast
hazelcast
3.5.3
com.hazelcast
hazelcast-spring
3.5.3
com.jayway.
jsonpath
json-path
2.0.0
com.jayway.
jsonpath
json-path-assert
2.0.0
com.samskivert
jmustache
1.11
com.sendgrid
sendgrid-java
2.2.2
com.sun.mail
javax.mail
1.5.4
com.timgroup
java-statsd-client
3.1.0
com.zaxxer
HikariCP
2.4.2
com.zaxxer
HikariCP-java6
2.3.12
commons
beanutils-commons-
beanutils
1.9.2
commons
collections-commons-
collections
3.2.1
commons
dbcp-commons-dbcp
1.4
commons
digester-commons-
digester
2.1
commons
pool-commons-pool
1.6
de.flapdoodle.
embed
de.flapdoodle.
embed.mongo
1.50.0
io.dropwizard.
metrics
metrics-core
3.1.2
io.dropwizard.
metrics
metrics-ganglia
3.1.2
io.dropwizard.
metrics
metrics-graphite
3.1.2
io.dropwizard.
metrics
metrics-servlets
3.1.2
io.projectreactor
reactor-bus
2.0.7.RELEASE
io.projectreactor
reactor-core
2.0.7.RELEASE
io.projectreactor
reactor-groovy
2.0.7.RELEASE
io.projectreactor
reactor-groovy-
extensions
2.0.7.RELEASE
io.projectreactor
reactor-logback
2.0.7.RELEASE
io.projectreactor
reactor-net
2.0.7.RELEASE
io.projectreactor
reactor-stream
2.0.7.RELEASE
io.projectreactor.
spring
reactor-spring-
context
2.0.6.RELEASE
io.projectreactor.
spring
reactor-spring-
core
2.0.6.RELEASE
io.projectreactor.
spring
reactor-spring-
messaging
2.0.6.RELEASE
io.projectreactor.
spring
reactor-spring-
webmvc
2.0.6.RELEASE
io.undertow
undertow-core
1.3.5.Final
io.undertow
undertow-servlet
1.3.5.Final
io.undertow
undertow-websockets-
jsr
1.3.5.Final
javax.cache
cache-api
1.0.0
javax.jms
jms-api
1.1-rev-1
javax.mail
javax.mail-api
1.5.4
javax.servlet
javax.servlet-api
3.1.0
javax.servlet
jstl
1.2
javax.transaction
javax.transaction-api
1.2
jaxen
jaxen
1.1.6
joda
time-joda-time
2.8.2
junit
junit
4.12
log4j
log4j
1.2.17
mysql
mysql-connector-java
5.1.37
net.sf.ehcache
ehcache
2.10.1
net.sourceforge.
nekohtml
nekohtml
1.9.22
nz.net.ultraq.
thymeleaf
thymeleaf-layout-
dialect
1.3.1
org.apache.activemq
activemq-amqp
5.12.1
org.apache.activemq
activemq-blueprint
5.12.1
org.apache.activemq
activemq-broker
5.12.1
org.apache.activemq
activemq-camel
5.12.1
org.apache.activemq
activemq-client
5.12.1
org.apache.activemq
activemq-console
5.12.1
org.apache.activemq
activemq-http
5.12.1
org.apache.activemq
activemq-jaas
5.12.1
org.apache.activemq
activemq-jdbc-
store
5.12.1
org.apache.activemq
activemq-jms-
pool
5.12.1
org.apache.activemq
activemq-kahadb-
store
5.12.1
org.apache.activemq
activemq-karaf
5.12.1
org.apache.activemq
activemq-leveldb-
store
5.12.1
org.apache.activemq
activemq-log4j-
appender
5.12.1
org.apache.activemq
activemq-mqtt
5.12.1
org.apache.activemq
activemq-openwire-
generator
5.12.1
org.apache.activemq
activemq-openwire-
legacy
5.12.1
org.apache.activemq
activemq-osgi
5.12.1
org.apache.activemq
activemq-partition
5.12.1
org.apache.activemq
activemq-pool
5.12.1
org.apache.activemq
activemq-ra
5.12.1
org.apache.activemq
activemq-run
5.12.1
org.apache.activemq
activemq-runtime-
config
5.12.1
org.apache.activemq
activemq-shiro
5.12.1
org.apache.activemq
activemq-spring
5.12.1
org.apache.activemq
activemq-stomp
5.12.1
org.apache.activemq
activemq-web
5.12.1
org.apache.activemq
artemis-jms-client
1.1.0
org.apache.activemq
artemis-jms-server
1.1.0
org.apache.commons
commons-dbcp2
2.1.1
org.apache.commons
commons-pool2
2.4.2
org.apache.derby
derby
10.12.1.1
org.apache.
httpcomponents
httpasyncclient
4.1.1
org.apache.
httpcomponents
httpclient
4.5.1
org.apache.
httpcomponents
httpcore
4.4.4
org.apache.
httpcomponents
httpmime
4.5.1
org.apache.
logging.log4j
log4j-api
2.4.1
org.apache.
logging.log4j
log4j-core
2.4.1
org.apache.
logging.log4j
log4j-slf4j-impl
2.4.1
org.apache.solr
solr-solrj
4.10.4
org.apache.
tomcat.embed
tomcat-embed-core
8.0.28
org.apache.
tomcat.embed
tomcat-embed-el
8.0.28
org.apache.
tomcat.embed
tomcat-embed-jasper
8.0.28
org.apache.
tomcat.embed
tomcat-embed-
logging-juli
8.0.28
org.apache.
tomcat.embed
tomcat-embed-
websocket
8.0.28
org.apache.tomcat
tomcat-jdbc
8.0.28
org.apache.tomcat
tomcat-jsp-api
8.0.28
org.apache.velocity
velocity
1.7
org.apache.velocity
velocity-tools
2.0
org.aspectj
aspectjrt
1.8.7
org.aspectj
aspectjtools
1.8.7
org.aspectj
aspectjweaver
1.8.7
org.codehaus.btm
btm
2.1.4
org.codehaus.
groovy
groovy
2.4.4
org.codehaus.
groovy
groovy-all
2.4.4
org.codehaus.
groovy
groovy-ant
2.4.4
org.codehaus.
groovy
groovy-bsf
2.4.4
org.codehaus.
groovy
groovy-console
2.4.4
org.codehaus.
groovy
groovy-docgenerator
2.4.4
org.codehaus.
groovy
groovy-groovydoc
2.4.4
org.codehaus.
groovy
groovy-groovysh
2.4.4
org.codehaus.
groovy
groovy-jmx
2.4.4
org.codehaus.
groovy
groovy-json
2.4.4
org.codehaus.
groovy
groovy-jsr223
2.4.4
org.codehaus.
groovy
groovy-nio
2.4.4
org.codehaus.
groovy
groovy-servlet
2.4.4
org.codehaus.
groovy
groovy-sql
2.4.4
org.codehaus.
groovy
groovy-swing
2.4.4
org.codehaus.
groovy
groovy-templates
2.4.4
org.codehaus.
groovy
groovy-test
2.4.4
org.codehaus.
groovy
groovy-testng
2.4.4
org.codehaus.
groovy
groovy-xml
2.4.4
org.codehaus.janino
janino
2.7.8
org.crashub
crash.cli
1.3.2
org.crashub
crash.connectors.ssh
1.3.2
org.crashub
crash.connectors.telnet
1.3.2
org.crashub
crash.embed.spring
1.3.2
org.crashub
crash.plugins.cron
1.3.2
org.crashub
crash.plugins.mail
1.3.2
org.crashub
crash.shell
1.3.2
org.eclipse.jetty
jetty-annotations
9.2.14.v20151106
org.eclipse.jetty
jetty-continuation
9.2.14.v20151106
org.eclipse.jetty
jetty-deploy
9.2.14.v20151106
org.eclipse.jetty
jetty-http
9.2.14.v20151106
org.eclipse.jetty
jetty-io
9.2.14.v20151106
org.eclipse.jetty
jetty-jsp
9.2.14.v20151106
org.eclipse.jetty
jetty-jmx
9.2.14.v20151106
org.eclipse.jetty
jetty-plus
9.2.14.v20151106
org.eclipse.jetty
jetty-security
9.2.14.v20151106
org.eclipse.jetty
jetty-server
9.2.14.v20151106
org.eclipse.jetty
jetty-servlet
9.2.14.v20151106
org.eclipse.jetty
jetty-servlets
9.2.14.v20151106
org.eclipse.jetty
jetty-util
9.2.14.v20151106
org.eclipse.jetty
jetty-webapp
9.2.14.v20151106
org.eclipse.jetty
jetty-xml
9.2.14.v20151106
org.eclipse.jetty.orbit
javax.servlet.jsp
2.2.0.v201112011158
org.eclipse.jetty.
websocket
javax-websocket-
server-impl
9.2.14.v20151106
org.eclipse.jetty.
websocket
websocket-server
9.2.14.v20151106
org.elasticsearch
elasticsearch
1.5.2
org.firebirdsql.jdbc
jaybird-jdk16
2.2.9
org.firebirdsql.jdbc
jaybird-jdk17
2.2.9
org.firebirdsql.jdbc
jaybird-jdk18
2.2.9
org.flywaydb
flyway-core
3.2.1
org.freemarker
freemarker
2.3.23
org.glassfish
javax.el
3.0.0
org.glassfish.
jersey.containers
jersey-container-
servlet
2.19
org.glassfish.
jersey.containers
jersey-container-
servlet-core
2.19
org.glassfish.
jersey.core
jersey-server
2.22.1
org.glassfish.
jersey.ext
jersey-bean-
validation
2.22.1
org.glassfish.
jersey.ext
jersey-spring3
2.22.1
org.glassfish.
jersey.media
jersey-media-
json-jackson
2.22.1
org.hamcrest
hamcrest-core
1.3
org.hamcrest
hamcrest-library
1.3
org.hibernate
hibernate-core
4.3.11.Final
org.hibernate
hibernate-ehcache
4.3.11.Final
org.hibernate
hibernate-entitymanager
4.3.11.Final
org.hibernate
hibernate-envers
4.3.11.Final
org.hibernate
hibernate-jpamodelgen
4.3.11.Final
org.hibernate
hibernate-validator
5.2.2.Final
org.hibernate
hibernate-validator-
annotation-processor
5.2.2.Final
org.hornetq
hornetq-jms-client
2.4.7.Final
org.hornetq
hornetq-jms-server
2.4.7.Final
org.hsqldb
hsqldb
2.3.3
org.infinispan
infinispan-jcache
8.0.1.Final
org.infinispan
infinispan-spring4
8.0.1.Final
org.javassist
javassist
3.18.1-GA
org.jdom
jdom2
2.0.6
org.jolokia
jolokia-core
1.3.2
org.json
json
20140107
org.jooq
jooq
3.7.1
org.jooq
jooq-meta
3.7.1
org.jooq
jooq-codegen
3.7.1
org.liquibase
liquibase-core
3.4.1
org.mariadb.jdbc
mariadb-java-client
1.2.3
org.mockito
mockito-core
1.10.19
org.mongodb
mongo-java-driver
2.13.3
org.postgresql
postgresql
9.4-1205-jdbc41
org.skyscreamer
jsonassert
1.2.3
org.slf4j
jcl-over-slf4j
1.7.13
org.slf4j
jul-to-slf4j
1.7.13
org.slf4j
log4j-over-slf4j
1.7.13
org.slf4j
slf4j-api
1.7.13
org.slf4j
slf4j-jdk14
1.7.13
org.slf4j
slf4j-log4j12
1.7.13
org.slf4j
slf4j-simple
1.7.13
org.spockframework
spock-core
1.0-groovy-2.4
org.spockframework
spock-spring
1.0-groovy-2.4
org.springframework
spring-core
4.2.3.RELEASE
org.springframework
spring-framework-bom
4.2.3.RELEASE
org.springframework
springloaded
1.2.4.RELEASE
org.springframework.
amqp
spring-amqp
1.5.2.RELEASE
org.springframework.
amqp
spring-rabbit
1.5.2.RELEASE
org.springframework.
batch
spring-batch-core
3.0.5.RELEASE
org.springframework.
batch
spring-batch-
infrastructure
3.0.5.RELEASE
org.springframework.
batch
spring-batch-
integration
3.0.5.RELEASE
org.springframework.
batch
spring-batch-test
3.0.5.RELEASE
org.springframework.
cloud
spring-cloud-
cloudfoundry-connector
1.2.0.RELEASE
org.springframework.
cloud
spring-cloud-core
1.2.0.RELEASE
org.springframework.
cloud
spring-cloud-
heroku-connector
1.2.0.RELEASE
org.springframework.
cloud
spring-cloud-
localconfig-connector
1.2.0.RELEASE
org.springframework.
cloud
spring-cloud-
spring-
service-connector
1.2.0.RELEASE
org.springframework.data
spring-data-
releasetrain-
Gosling-SR1RELEASE
org.springframework.
hateoas
spring-hateoas
0.19.0.RELEASE
org.springframework.
integration
spring-integration-
bom
4.2.1.RELEASE
org.springframework.
integration
spring-integration-
http
4.2.1.RELEASE
org.springframework.
mobile
spring-mobile-device
1.1.5.RELEASE
org.springframework.
plugin
spring-plugin-core
1.2.0.RELEASE
org.springframework.
retry
spring-retry
1.1.2.RELEASE
org.springframework.
security
spring-security-
bom
4.0.3.RELEASE
org.springframework.
security
spring-security-
jwt
1.0.3.RELEASE
org.springframework.
security.oauth
spring-security-
oauth
2.0.8.RELEASE
org.springframework.
security.oauth
spring-security-
oauth2
2.0.8.RELEASE
org.springframework.
session
spring-session
1.0.2.RELEASE
org.springframework.
session
spring-session-
data-redis
1.0.2.RELEASE
org.springframework.
social
spring-social-config
1.1.3.RELEASE
org.springframework.
social
spring-social-core
1.1.3.RELEASE
org.springframework.
social
spring-social-security
1.1.3.RELEASE
org.springframework.
social
spring-social-web
1.1.3.RELEASE
org.springframework.
social
spring-social-facebook
2.0.2.RELEASE
org.springframework.
social
spring-social-facebook-web
2.0.2.RELEASE
org.springframework.
social
spring-social-linkedin
1.0.2.RELEASE
org.springframework.
social
spring-social-twitter
1.1.2.RELEASE
org.springframework.ws
spring-ws-core
2.2.3.RELEASE
org.springframework.ws
spring-ws-security
2.2.3.RELEASE
org.springframework.ws
spring-ws-support
2.2.3.RELEASE
org.springframework.ws
spring-ws-test
2.2.3.RELEASE
org.thymeleaf
thymeleaf
2.1.4.RELEASE
org.thymeleaf
thymeleaf-spring4
2.1.4.RELEASE
org.thymeleaf.
extras
thymeleaf-extras-
conditionalcomments
2.1.1.RELEASE
org.thymeleaf.
extras
thymeleaf-extras-
springsecurity4
2.1.2.RELEASE
org.webjars
hal-browser
9f96c74
org.yaml
snakeyaml
1.16
redis.clients
jedis
2.7.3
wsdl4j
wsdl4j
1.6.3