构建系统
强烈建议你选择一个支持 依赖管理 并且可以使用发布到 Maven Central 仓库的构件的构建系统。 我们建议你选择 Maven 或 Gradle。 虽然可以让 Spring Boot 与其他构建系统(例如 Ant)一起工作,但它们并没有得到特别好的支持。
依赖管理
每个 Spring Boot 版本都提供了一个它支持的依赖项列表。 实际上,你不需要在构建配置中为这些依赖项提供版本,因为 Spring Boot 会为你管理这些。 当你升级 Spring Boot 本身时,这些依赖项也会以一致的方式升级。
如果需要,你仍然可以指定版本并覆盖 Spring Boot 的建议。 |
这个精选列表包含了你可以在 Spring Boot 中使用的所有 Spring 模块以及精选的第三方库列表。
该列表作为标准的物料清单(spring-boot-dependencies
)提供,可以与 Maven 和 Gradle 一起使用。
每个 Spring Boot 版本都与 Spring Framework 的基础版本相关联。 我们强烈建议你不要指定其版本。 |
Ant
可以使用 Apache Ant+Ivy 构建 Spring Boot 项目。
spring-boot-antlib
“AntLib” 模块也可用于帮助 Ant 创建可执行 jar。
要声明依赖项,典型的 ivy.xml
文件如下所示:
<ivy-module version="2.0">
<info organisation="org.springframework.boot" module="spring-boot-sample-ant" />
<configurations>
<conf name="compile" description="everything needed to compile this module" />
<conf name="runtime" extends="compile" description="everything needed to run this module" />
</configurations>
<dependencies>
<dependency org="org.springframework.boot" name="spring-boot-starter"
rev="${spring-boot.version}" conf="compile" />
</dependencies>
</ivy-module>
典型的 build.xml
如下所示:
<project
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:spring-boot="antlib:org.springframework.boot.ant"
name="myapp" default="build">
<property name="spring-boot.version" value="3.4.6" />
<target name="resolve" description="--> retrieve dependencies with ivy">
<ivy:retrieve pattern="lib/[conf]/[artifact]-[type]-[revision].[ext]" />
</target>
<target name="classpaths" depends="resolve">
<path id="compile.classpath">
<fileset dir="lib/compile" includes="*.jar" />
</path>
</target>
<target name="init" depends="classpaths">
<mkdir dir="build/classes" />
</target>
<target name="compile" depends="init" description="compile">
<javac srcdir="src/main/java" destdir="build/classes" classpathref="compile.classpath" />
</target>
<target name="build" depends="compile">
<spring-boot:exejar destfile="build/myapp.jar" classes="build/classes">
<spring-boot:lib>
<fileset dir="lib/runtime" />
</spring-boot:lib>
</spring-boot:exejar>
</target>
</project>
如果你不想使用 spring-boot-antlib 模块,请参阅 “How-to Guides” 中的 在不使用 spring-boot-antlib 的情况下使用 Ant 构建可执行归档 部分。
|
Starters
Starters 是一组方便的依赖描述符,你可以将它们包含在你的应用程序中。
你可以一站式获取所有需要的 Spring 和相关技术,而不必在示例代码中查找和复制粘贴大量的依赖描述符。
例如,如果你想开始使用 Spring 和 JPA 进行数据库访问,请在项目中包含 spring-boot-starter-data-jpa
依赖。
Starters 包含了许多你需要快速启动和运行项目的依赖项,并提供了一组一致的、受管理的传递依赖项。
以下应用程序 starters 由 Spring Boot 在 org.springframework.boot
组下提供:
Name | Description |
---|---|
Core starter, including auto-configuration support, logging and YAML |
|
Starter for JMS messaging using Apache ActiveMQ |
|
Starter for using Spring AMQP and Rabbit MQ |
|
Starter for aspect-oriented programming with Spring AOP and AspectJ |
|
Starter for JMS messaging using Apache Artemis |
|
Starter for using Spring Batch |
|
Starter for using Spring Framework’s caching support |
|
Starter for using Cassandra distributed database and Spring Data Cassandra |
|
Starter for using Cassandra distributed database and Spring Data Cassandra Reactive |
|
Starter for using Couchbase document-oriented database and Spring Data Couchbase |
|
Starter for using Couchbase document-oriented database and Spring Data Couchbase Reactive |
|
Starter for using Elasticsearch search and analytics engine and Spring Data Elasticsearch |
|
Starter for using Spring Data JDBC |
|
Starter for using Spring Data JPA with Hibernate |
|
Starter for using Spring Data LDAP |
|
Starter for using MongoDB document-oriented database and Spring Data MongoDB |
|
Starter for using MongoDB document-oriented database and Spring Data MongoDB Reactive |
|
Starter for using Neo4j graph database and Spring Data Neo4j |
|
Starter for using Spring Data R2DBC |
|
Starter for using Redis key-value data store with Spring Data Redis and the Lettuce client |
|
Starter for using Redis key-value data store with Spring Data Redis reactive and the Lettuce client |
|
Starter for exposing Spring Data repositories over REST using Spring Data REST and Spring MVC |
|
Starter for building MVC web applications using FreeMarker views |
|
Starter for building GraphQL applications with Spring GraphQL |
|
Starter for building MVC web applications using Groovy Templates views |
|
Starter for building hypermedia-based RESTful web application with Spring MVC and Spring HATEOAS |
|
Starter for using Spring Integration |
|
Starter for using JDBC with the HikariCP connection pool |
|
Starter for building RESTful web applications using JAX-RS and Jersey. An alternative to |
|
Starter for using jOOQ to access SQL databases with JDBC. An alternative to |
|
Starter for reading and writing json |
|
Starter for using Java Mail and Spring Framework’s email sending support |
|
Starter for building web applications using Mustache views |
|
Starter for using Spring Authorization Server features |
|
Starter for using Spring Security’s OAuth2/OpenID Connect client features |
|
Starter for using Spring Security’s OAuth2 resource server features |
|
Starter for using Spring for Apache Pulsar |
|
Starter for using Spring for Apache Pulsar Reactive |
|
Starter for using the Quartz scheduler |
|
Starter for building RSocket clients and servers |
|
Starter for using Spring Security |
|
Starter for testing Spring Boot applications with libraries including JUnit Jupiter, Hamcrest and Mockito |
|
Starter for building MVC web applications using Thymeleaf views |
|
Starter for using Java Bean Validation with Hibernate Validator |
|
Starter for building web, including RESTful, applications using Spring MVC. Uses Tomcat as the default embedded container |
|
Starter for using Spring Web Services |
|
Starter for building WebFlux applications using Spring Framework’s Reactive Web support |
|
Starter for building WebSocket applications using Spring Framework’s MVC WebSocket support |
除了应用程序 starters 之外,以下 starters 可用于添加 生产就绪 功能:
Name | Description |
---|---|
Starter for using Spring Boot’s Actuator which provides production ready features to help you monitor and manage your application |
最后,Spring Boot 还包括以下 starters,如果你想排除或交换特定的技术方面,可以使用它们:
Name | Description |
---|---|
Starter for using Jetty as the embedded servlet container. An alternative to |
|
Starter for using Log4j2 for logging. An alternative to |
|
Starter for logging using Logback. Default logging starter |
|
Starter for using Reactor Netty as the embedded reactive HTTP server. |
|
Starter for using Tomcat as the embedded servlet container. Default servlet container starter used by |
|
Starter for using Undertow as the embedded servlet container. An alternative to |
要了解如何交换技术方面,请参阅有关 交换 Web 服务器 和 日志系统 的 how-to 文档。
有关其他社区贡献的 starters 列表,请参阅 GitHub 上 spring-boot-starters 模块中的 README 文件。
|