第一节:SpringBoot 简介

主要是简化开发;

1. 创建独立的Spring应用程序

2. 嵌入的Tomcat,无需部署WAR文件

3. 简化Maven配置

4. 自动配置Spring

5. 提供生产就绪型功能,如指标,健康检查和外部配置

6. 绝对没有代码生成和对XML没有要求配置

第二节:STS 插件安装

注意:StS插件运行必须是JDK1.8 否则会出现安装失败的情况;

Eclipse 菜单栏 Help -> Eclipse Marketplace...Popular,下载sts(spring tool suite),安装完之后重启生效;

安装参考:http://blog.java1234.com/blog/articles/330.html

第三节:SpringBoot HelloWorld 实现

插件安装完毕,然后我们来新建一个SpringBoot项目

新建 选择 Spring->Spring Starter Project

到了 配置依赖的界面,我们这里暂时不需要用到其他的,仅选择一个Web依赖即可;

生成的项目结构:

查看自动创建的文件:

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>com.cy</groupId>
<artifactId>HelloWorld</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging> <name>HelloWorld</name>
<description>Demo project for Spring Boot</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>

com.cy.HelloWorldApplication.java:--启动类;

package com.cy;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication
public class HelloWorldApplication { public static void main(String[] args) {
SpringApplication.run(HelloWorldApplication.class, args);
}
}

HelloWorldApplication是启动类,我们右击Run As 选择 Spring Boot app

这里我们不需要Tomcat 因为SpringBoot把Tomcat集成了,默认端口8080

浏览器输入:http://localhost:8080/

出现

Whitelabel Error Page

说明项目启动成功;

写一个helloworld请求:

com.cy.controller.HelloWorldController.java:

package com.cy.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; @RestController
public class HelloWorldController { @RequestMapping("/helloWorld")
public String say(){
return "spring boot你好";
}
}

重启项目,浏览器输入http://localhost:8080/helloWorld

说明:

1.@RestController相当于之前的@Controller和@ResponseBody;

2.这里相当于返回一个json,类似于ajax请求,返回的是一个字符串;

-------

spring boot学习(1) hello world的更多相关文章

  1. Spring Boot学习大全(入门)

    Spring Boot学习(入门) 1.了解Spring boot Spring boot的官网(https://spring.io),我们需要的一些jar包,配置文件都可以在下载.添置书签后,我自己 ...

  2. Spring Boot学习记录(二)--thymeleaf模板 - CSDN博客

    ==他的博客应该不错,没有细看 Spring Boot学习记录(二)--thymeleaf模板 - CSDN博客 http://blog.csdn.net/u012706811/article/det ...

  3. Spring boot学习1 构建微服务:Spring boot 入门篇

    Spring boot学习1 构建微服务:Spring boot 入门篇 Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框 ...

  4. spring boot 学习资料

    spring boot 学习资料: 学习资料 网址 Spring Boot Cookbook-极客学院 http://wiki.jikexueyuan.com/project/spring-boot- ...

  5. Spring Boot学习笔记2——基本使用之最佳实践[z]

    前言 在上一篇文章Spring Boot 学习笔记1——初体验之3分钟启动你的Web应用已经对Spring Boot的基本体系与基本使用进行了学习,本文主要目的是更加进一步的来说明对于Spring B ...

  6. spring boot 学习(十四)SpringBoot+Redis+SpringSession缓存之实战

    SpringBoot + Redis +SpringSession 缓存之实战 前言 前几天,从师兄那儿了解到EhCache是进程内的缓存框架,虽然它已经提供了集群环境下的缓存同步策略,这种同步仍然需 ...

  7. 转载:spring boot学习

    Spring Boot学习 Spring Boot是为了简化Spring应用的创建.运行.调试.部署等而出现的,使用它可以做到专注于Spring应用的开发,而无需过多关注XML的配置. 简单来说,它提 ...

  8. Spring Boot学习路线

    Spring Boot 学习路线,本文计划根据作者近几年的工作.学习经验,来分析和制定一个学习使用 Spring Boot技术的步骤路线图. SpringBoot是伴随着Spring4.0诞生的: S ...

  9. 我的Spring Boot学习记录(二):Tomcat Server以及Spring MVC的上下文问题

    Spring Boot版本: 2.0.0.RELEASE 这里需要引入依赖 spring-boot-starter-web 这里有可能有个人的误解,请抱着怀疑态度看. 建议: 感觉自己也会被绕晕,所以 ...

  10. 15 个优秀开源的 Spring Boot 学习项目,一网打尽!

    Spring Boot 算是目前 Java 领域最火的技术栈了,松哥年初出版的 <Spring Boot + Vue 全栈开发实战>迄今为止已经加印了 8 次,Spring Boot 的受 ...

随机推荐

  1. 取TTable 过滤后的记录数

    http://bbs.csdn.net/topics/100057274 可以用AstaClientDataSet这个控件,有filterCount这个属性.另外你还可看它的源码,就能写出filter ...

  2. xitong

    回复 YAJE3 :http://msdn.anjieart.net/和http://msdn.ez58.net/files/windows%20vista同样是MSDN网站 msdnitellyou ...

  3. STL标准库-迭代器

    技术在于交流.沟通,本文为博主原创文章转载请注明出处并保持作品的完整性 本节主要介绍STL六大部件中的Iterators迭代器. 在语言方面讲,容器是一个class template, 算法是一个仿函 ...

  4. Intellij Idea2016.3 svn服务器拉取代码

    1.修改idea的默认配置,取消SVN设置里的两个勾 2.拉取代码 3.输入SVN仓库的地址,然后checkout 即可

  5. Use JAWS 14 in a VM

    We were not able to run the JAWS 14 app in a Virtual Machine after the installation is completed, th ...

  6. XDocument 使用

    摘要: 正文: 1.引入XDocument的命名空间 using System.Xml.Linq; 2. List<CourseItem> to XML doc //List<Cou ...

  7. how to get keyboard key with non blocking in terminal

    /************************************************************************** * how to get keyboard ke ...

  8. STM32 用c语言控制4个LED灯从左向右无限流动

    在用c语言写LED流水灯的前提条件是配置好其他环境,这里我就不说环境了, 想让LED灯无限循环时,首先要想到的是无限循环函数,我这里利用的是for函数 无限循环. #include "stm ...

  9. Unity 3D中 Ulua-UGUI简单的Demo——热更新的具体流程、使用说明

    Ulua热更新具体流程.使用说明 本文提供全流程,中文翻译.Chinar坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) 1 -- 未完 1 -- ...

  10. HDU 1872:稳定排序

    稳定排序 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...