`
wenjinglian
  • 浏览: 806101 次
  • 性别: Icon_minigender_1
  • 来自: 株洲->深圳
社区版块
存档分类
最新评论

Spring Boot 快速入门 (官方quick start)

阅读更多

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.

 

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.2.1.RELEASE</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

 

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

 

分享到:
评论
1 楼 小黄牛 2016-12-08  
很好谢谢分享!推荐几篇spring boot基础入门文章:http://www.roncoo.com/article/detail/124661

相关推荐

    spring-boot很多实例

    包括'chapter-2-spring-boot-quick-start','chapter-4-spring-boot-validating-form-input','chapter-5-spring-boot-paging-sorting','doc','springboot-configuration','springboot-dubbo-client','springboot-...

    spring-boot-quick-start

    spring-boot-quick-start

    spring-boot-data-jpa-example:Spring Boot!学习之Spring-Data-Jpa

    quick start # build mvn clean install # run mvn spring-boot:run 数据库配置 spring.jpa.hibernate.ddl-auto: create 启动时生成表 spring.jpa.hibernate.ddl-auto: create-drop 启动时生成表,关闭时删除表结构...

    spring-boot-reference.pdf

    10.2.6. Quick-start Spring CLI Example 10.3. Upgrading from an Earlier Version of Spring Boot 11. Developing Your First Spring Boot Application 11.1. Creating the POM 11.2. Adding Classpath ...

    eapp-personal-quick-start-master.zip

    阿里钉钉开放平台spring boot 后端java 钉钉小程序 demo 工程项目!

    tdc-2015-spring-boot

    02-blank- project-空白项目,带有几乎为空的pom文件03-quick-start-dependencies-添加spring-boot maven依赖项04-add-tdc- banner-将banner.txt文件添加到项目05-胡子和待办事项文件-添加视图依赖项并复制到...

    xmljava系统源码-MS:管理系统演示

    Quick Start 项目使用到的技术有 Spring Boot Mybatis-Plus Swagger2 JAVA Mail Spring AOP 持续更新中... 实现的功能有 实现了邮件发送和公共文件上传 自定义分页查询,Mybatis plus实现通用CRUD 全局异常处理及...

    word源码java-smart_elk_client:elasticsearchjava客户端

    word源码java recommend elastic search java客户端,使用retrofit + rxjava2 沟通elk的rest端点进行索引,文档和查询相关操作。 使用简单,支持elk多...如果你是spring-boot或其他spring项目,在resource path下的a

    Cubic java应用诊断工具-其他

    技术体系:Spring Boot、Vue、Netty、Websocket、xterm等。目录结构:agent-dist 存放打包的agent.jar(打包后出现)agent-proxy-dist 存放打包的proxy.jar(打包后出现)arthas-dist 用于支持arthas命令集config agent...

    itpub.net]summit2

    START WITH 216 NOCACHE NOORDER NOCYCLE; DROP SEQUENCE s_dept_id; CREATE SEQUENCE s_dept_id MINVALUE 1 MAXVALUE 9999999 INCREMENT BY 1 START WITH 51 NOCACHE NOORDER NOCYCLE; DROP SEQUENCE s_...

Global site tag (gtag.js) - Google Analytics