创建项目:

项目结构:

程序启动入口:

正式开始:

 package com.example.demo;

 import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan; @SpringBootApplication
@ComponentScan("com.example.helloweb") //扫描所需要的包
public class DemoApplication { public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}

HelloWorld:

 package com.example.helloweb;

 import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; @Controller
public class HelloWord { /**
* @Controller 和 @ResponseBody 配合相当于 @RestController,
* 返回前端页面的都是 json 格式数据。
* @return
*/
@RequestMapping("/hello")
public @ResponseBody String index () {
System.out.println("欢迎进入SpringBoot");
return "Hello World!";
}
}

 控制台显示:

欢迎进入SpringBoot

页面显示:

搞定!

最新文章

  1. 中文字符匹配js正则表达式
  2. lucene-查询query->RangeQuery在某一范围内搜索
  3. Divide and Conquer:Cable Master(POJ 1064)
  4. jsoup 简介
  5. 最小生成树(HDOJ 1863)
  6. HTML5 :b/strong加粗,i/em倾斜区别
  7. linux驱动程序之电源管理之标准linux休眠和唤醒机制分析(二)
  8. QT中嵌入SDL
  9. 第一篇:NSOperation的概念
  10. 微软Surface Book推送Windows 10新固件更新:增强系统和电池
  11. 自己实现ArrayList
  12. Go语言数组
  13. TMS-规划图
  14. windows下安装ElasticSearch的Head插件
  15. 使用监听器解决路径问题,例如在jsp页面引入js,css的web应用路径
  16. python socket 详细介绍
  17. U盘装系统:安装GHOST Win7系统教程
  18. python2.7入门---函数
  19. Git命令行中文显示错误
  20. hadoop中使用的Unsafe.java

热门文章

  1. python学习之函数基础
  2. The Road to learn React书籍学习笔记(第四章)
  3. Sqoop帮助文档
  4. 1、Java多线程基础:进程和线程之由来
  5. css匹配规则及性能
  6. ASP NET Core --- 资源塑形, HATEOAS, Media Type
  7. Git&GitHub&GitBook
  8. Android之ViewPager 第一课
  9. PostgreSQL 建库建表脚本
  10. vue-component=>v-on