一. What: Spring Boot是什么?
以1.4.3.RELEASE为例,官方介绍为:http://docs.spring.io/spring-boot/docs/1.4.3.RELEASE/reference/html/getting-started-introducing-spring-boot.html 。

简单来说,使用Spring Boot能够非常方便,快速地开发一个基于Spring框架,可独立运行的应用程序。

具体来说,Spring Boot集成了一些在项目中常用的组件,比如:嵌入式服务器,安全等。而且在使用Spring Boot开发应用程序时,完全不需要XML配置。

二. Why: 为什么Spring Boot能如此易用?
//TODO: 随后再详细介绍

三. How: 如何建立一个简单的Spring Boot应用程序?

环境要求:
1. JDK: Although you can use Spring Boot with Java 6 or 7, we generally recommend Java 8 if at all possible. 
2. Maven: Spring Boot is compatible with Apache Maven 3.2 or above.

示例项目:

1. 新建一个maven项目,并在pom.xml中添加如下依赖配置:

 <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>org.chench</groupId>
<artifactId>springboot-hellworld</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging> <name>springboot-hellworld</name>
<url>http://maven.apache.org</url> <!-- 使用spring boot框架:声明spring boot为父依赖 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.3.RELEASE</version>
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <dependencies>
<!-- 开发web应用 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies> <build>
<plugins>
<!-- 打包插件: 可将项目打包为独立执行的jar文件 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>

2. 新建HelloWordApplication:

 @RestController
@EnableAutoConfiguration
public class HelloWordApplication { @RequestMapping("/")
public String helloworld() {
return "hello,world";
} public static void main(String[] args) {
SpringApplication.run(HelloWordApplication.class, args);
}
}

3.运行HelloWordApplication:
如果是在eclipse等开发环境中,直接运行: "Run As" -> "Java Application" 。
或者,直接将项目打包为可独立执行的jar文件: mvn clean package,将生成文件: springboot-hellworld-version.jar 。 执行如下命令启动项目: java -jar springboot-hellworld-version.jar

启动之后,在浏览器地址栏输入: http://localhost:8080/

完毕!

Spring Boot系列之-helloword入门的更多相关文章

  1. Spring Boot 系列总目录

    一.Spring Boot 系列诞生原因 上学那会主要学的是 Java 和 .Net 两种语言,当时对于语言分类这事儿没什么概念,恰好在2009年毕业那会阴差阳错的先找到了 .Net 的工作,此后就开 ...

  2. spring boot 系列之五:spring boot 通过devtools进行热部署

    前面已经分享过四篇随笔: spring boot 系列之一:spring boot 入门 spring boot 系列之二:spring boot 如何修改默认端口号和contextpath spri ...

  3. Spring Boot 系列教程19-后台验证-Hibernate Validation

    后台验证 开发项目过程中,后台在很多地方需要进行校验操作,比如:前台表单提交,调用系统接口,数据传输等.而现在多数项目都采用MVC分层式设计,每层都需要进行相应地校验. 针对这个问题, JCP 出台一 ...

  4. Spring Boot 系列教程18-itext导出pdf下载

    Java操作pdf框架 iText是一个能够快速产生PDF文件的java类库.iText的java类对于那些要产生包含文本,表格,图形的只读文档是很有用的.它的类库尤其与java Servlet有很好 ...

  5. Spring Boot 系列教程17-Cache-缓存

    缓存 缓存就是数据交换的缓冲区(称作Cache),当某一硬件要读取数据时,会首先从缓存中查找需要的数据,如果找到了则直接执行,找不到的话则从内存中找.由于缓存的运行速度比内存快得多,故缓存的作用就是帮 ...

  6. Spring Boot 系列教程16-数据国际化

    internationalization(i18n) 国际化(internationalization)是设计和制造容易适应不同区域要求的产品的一种方式. 它要求从产品中抽离所有地域语言,国家/地区和 ...

  7. Spring Boot 系列教程15-页面国际化

    internationalization(i18n) 国际化(internationalization)是设计和制造容易适应不同区域要求的产品的一种方式. 它要求从产品中抽离所有地域语言,国家/地区和 ...

  8. Spring Boot 系列教程14-动态修改定时任务cron参数

    动态修改定时任务cron参数 不需要重启应用就可以动态的改变Cron表达式的值 不能使用@Scheduled(cron = "${jobs.cron}")实现 DynamicSch ...

  9. Spring Boot 系列教程12-EasyPoi导出Excel下载

    Java操作excel框架 Java Excel俗称jxl,可以读取Excel文件的内容.创建新的Excel文件.更新已经存在的Excel文件,现在基本没有更新了 http://jxl.sourcef ...

随机推荐

  1. Linux 之 光标消失隐藏术

    下面是 Linux 光标突然不见的解决办法: 直接敲命令行就行 echo -e "\033[?25l"  隐藏光标 echo -e "\033[?25h" 显示 ...

  2. HttpMessageConverter(消息转换器 )和@responsebody使用(转)

    @responsebody表示该方法的返回结果直接写入HTTP response body中 一般在异步获取数据时使用,在使用@RequestMapping后,返回值通常解析为跳转路径,加上@resp ...

  3. iota妙用

    itoa可以套公式,下面的依旧会按照公式运算 package main import "fmt" func main() { const ( b = 1 << (10 ...

  4. git如何统计代码行数

    1.根据用户名时间段统计 git log --author="username" --since=2018-01-01 --until=2019-12-31 --pretty=tf ...

  5. 3 Ways to Force Unmount in Linux Showing “device is busy”

    3 Ways to Force Unmount in Linux Showing “device is busy” Updated August 8, 2019By Bobbin ZachariahL ...

  6. HEXO的使用

    本文将总结性的介绍如何建立自己的github.io博客,后续会持续补充,进阶.感谢baixin提供的参考文章. 技术选型为github+hexo+idea,首先最简单的阐述下这个东西都干嘛的 1. 技 ...

  7. am335x system upgrade kernel ec20 simcom7600ce(十一)

    1      Scope of Document This document describes 4G hardware design, support quectel ec20 4G module/ ...

  8. web基本概念

    一.互联网 互联网(英语:Internet),又称网际网络,或音译因特网(Internet).英特网,互联网始于1969年美国的阿帕网.是网络与网络之间所串连成的庞大网络,这些网络以一组通用的协议相连 ...

  9. word collocations中文版(信息检索)

    虽然说是大作业,也做了好几天,但是完全没有什么实际价值...就是把现有的东西东拼西凑一下,发现跑的特别慢还搞了个多核 写这篇blog纯属是我吃饱了没事干,记录一下装env的蛋疼 首先我们是在pytho ...

  10. LibreOJ #527. 「LibreOJ β Round #4」框架

    二次联通门 : LibreOJ #527. 「LibreOJ β Round #4」框架 /* LibreOJ #527. 「LibreOJ β Round #4」框架 %% xxy dalao 对于 ...