Spring Boot二:创建第一个web工程 hello world

一.创建工程

创建名称为"springboot_helloworld"的spring boot工程, new->Spring Starter Project,直接上图

0?wx_fmt=png

0?wx_fmt=jpeg

0?wx_fmt=jpeg

点击“Finish”后需要耐心等待,这时Maven会自动下载所需spring boot的依赖包。所有的依赖如下:

0?wx_fmt=jpeg                    0?wx_fmt=jpeg

二.开始编码

2.1 新建WebController

package com.woniu.controller;

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

@RestController
@RequestMapping(value="/index")
public class WebController {
	
	@RequestMapping(value="/hello")
	public String helloworld(){
		return "hello world!";
	}
}

2.2 启动工程

0?wx_fmt=jpeg

0?wx_fmt=jpeg

三.测试

0?wx_fmt=jpeg

0?wx_fmt=jpeg


posted @ 2017-07-21 13:29  Java技术头条  阅读(73)  评论(0编辑  收藏  举报