Spring Boot 可以很简的创建单独,生产级基于Spring 的应用并且可以直接运行。我们将Spring 平台和第三方依赖包全部整合在一起,因些你很简单的就能使用起来。大多数的Spring Boot 应用仅仅只需要一丁点Spring 配置。
特性:
- 创建独立的Spring 应用
- 嵌入Tomcat, Jetty 或者 Undertow 直接运行(不需要发布成 war 文件)
- 提供固定的"starter" 配置在pom.xml中简化你的Maven配置
- 尽可能的自动化配置Spring
- 提供发布生产一些功能如:指标,健康检测和外部配置
- 完全没有代码生成和xml的配置的配置要求
这个参考指南reference guide 包含了详情的功能使用,附加一个广泛howto使用的公共案例。
快速入门
Spring Boot 附带一个命令行工具,如果你想用来快速开发Spring那么可以使用。他可以允许你运行Groovy
脚本, 这意味着你需要熟悉一个类似java 语法,没有太多模版代码的工具。如果你要那么按照我们主要文档 install the Spring Boot CLI。
如果你是一个Java 开发者,你可以使用 start.spring.io 创建一个基本的项目,按下面的 “快速入门”例子,或者阅读参考文档中的 getting started 指南
推荐的一种方式刚开始在你的项目中使用 spring-boot 可以作为一个依赖管理系统 - 将下面简单的代码片断复制并且粘贴到你的build 文件中。 需要帮助吗? 看一下我们入门指南中 构建使用 Maven and Gradle.
org.springframework.boot spring-boot-starter-parent 1.2.1.RELEASE org.springframework.boot spring-boot-starter-web
hello/SampleController.java
package hello; import org.springframework.boot.*; import org.springframework.boot.autoconfigure.*; import org.springframework.stereotype.*; import org.springframework.web.bind.annotation.*; @Controller @EnableAutoConfiguration public class SampleController { @RequestMapping("/") @ResponseBody String home() { return "Hello World!"; } public static void main(String[] args) throws Exception { SpringApplication.run(SampleController.class, args); } }
官方地址: http://projects.spring.io/spring-boot/
Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that can you can "just run". We take an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration.
Features
- Create stand-alone Spring applications
- Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)
- Provide opinionated 'starter' POMs to simplify your Maven configuration
- Automatically configure Spring whenever possible
- Provide production-ready features such as metrics, health checks and externalized configuration
- Absolutely no code generation and no requirement for XML configuration
The reference guide includes detailed descriptions of all the features, plus an extensivehowto for common use cases.
Quick Start
Spring Boot ships with a command line tool that can be used if you want to quickly prototype with Spring. It allows you to run Groovy scripts, which means that you have a familiar Java-like syntax, without so much boilerplate code. Follow the instructions in our main documentation if you want to install the Spring Boot CLI.
If you are Java developer you can use start.spring.io to generate a basic project, follow the "Quick Start" example below, or read the reference documentation getting started guide.
The recommended way to get started using spring-boot
in your project is with a dependency management system – the snippet below can be copied and pasted into your build. Need help? See our getting started guides on building with Maven and Gradle.
demo: hello.zip下载
环境:
maven
jdk:1.6+
cmd -> mvn spring-boot:run
启动成功访问:http://localhost:8080