一. 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. oracle+mybatis报错:BindingException("Invalid bound statement (not found): ")

    oracle+mybatis报错:BindingException("Invalid bound statement (not found): ") 从mysql转到oracle数 ...

  2. byte[] 转 2进制字符串

    /byte[]转为二进制字符串表示byte[] bytesTest =new byte[]{16,18,33}; string strResult=string.Empty;string strTem ...

  3. mysql 5.7.21, for Linux (i686) 权限配置

    配置权限参数: GRANT语法: GRANT 权限 ON 数据库.* TO 用户名@'登录主机' IDENTIFIED BY '密码' 权限: ALL,ALTER,CREATE,DROP,SELECT ...

  4. POJ 2987 Firing 最大流 网络流 dinic 模板

    https://www.cnblogs.com/137shoebills/p/9100790.html http://poj.org/problem?id=2987 之前写过这道题,码一个dinic的 ...

  5. CF Gym 102028G Shortest Paths on Random Forests

    CF Gym 102028G Shortest Paths on Random Forests 抄题解×1 蒯板子真jir舒服. 构造生成函数,\(F(n)\)表示\(n\)个点的森林数量(本题都用E ...

  6. loadRunner目录分析<二>

    loadRunner是用C语言进行编写的所以很多文件都是以.h文件结尾的 挑选一部分关键目录结构进行说明 1.analysis templates --分析模板,案例模板 2.bin --可执行程序, ...

  7. mysql 统计查询出来的数目

    select count(*) as dd from users;

  8. 判断qq浏览器和uc浏览器?

    判断在iphone手机上打开的是uc浏览器还是qq浏览器 <html lang="en"> <head> <meta charset="ut ...

  9. Java 面向对象(十五)

    Lambda表达式 1. 函数式编程思想概述 在数学中,函数就是有输入量.输出量的一套计算方案,也就是"拿什么东西做什么事情".相对而言,面向对象过分强调"必须通过对象的 ...

  10. Assignment5: 使用Visual Studio 进行可编码的UI测试

    一.实验目的: 使用Visual Studio 可编码的UI测试功能创作自动化测试 二.实验原理:黑盒测试 三.实验需求:win8 app.Visual Studio Ultimate 2012/20 ...