使用Maven构建Spring Boot 第一课之Hello world 程序

Spring Boot 学习第一课

这里写图片描述

官网
https://spring.io/

学习手册
https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/

入门指南
https://spring.io/guides/gs/spring-boot/

准备开始

JDK1.8 +
Gradle 2.3+ or Maven 3.0+
IDE
Spring  Tool Suite (STS)  https://spring.io/tools/sts/
Intellij IDEA https://www.jetbrains.com/idea/

获取模板源码

可选以下三种方式 Optional
1. git clone https://github.com/spring-guides/gs-spring-boot.git
2. https://github.com/spring-guides/gs-spring-boot/archive/master.zip
3. https://start.spring.io/

使用Intellij IDEA 开发指南

  1. 运行Intellij IDEA,点击 ’ Create New Project ‘

这里写图片描述

2.如图所示:

这里写图片描述

3.如图所示:

这里写图片描述

4.如图所示:
这里写图片描述

5.如图所示:

这里写图片描述

6.点击Finish之后可以看到如下所示:

这里写图片描述

7.点击运行后可以看到这样的界面:

http://127.0.0.1:8080

这里写图片描述

8.创建一个叫做HelloController的java 类

这里写图片描述

package com.xingyun.springbootwithmavensample;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@RestController
public class HelloController {
  @RequestMapping(value = “/hi",method = RequestMethod.GET)            
  public String index(){
       return "Hello World , Spring Boot";
  }
 }

重新运行,打开链接:http://127.0.0.1:8080/hi

这里写图片描述

源码下载地址:https://gitee.com/xingyuncode/SpringBootWithMavenSample

猜你喜欢

转载自blog.csdn.net/hadues/article/details/78694316