1、创建spring bootproject

SpringBoot-HelloWorldSpringBoot-HelloWorldSpringBoot-HelloWorldSpringBoot-HelloWorldSpringBoot-HelloWorld

2、工程结构

SpringBoot-HelloWorld

3、修改maven LocalRepository地址

SpringBoot-HelloWorld

4、编写测试类HelloController

package com.glodon.springboot.controller;

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

/**
 * Created by zhangh-ag on 2017-06-11.
 */
/* RestController实现
@Target(value=TYPE)
@Retention(value=RUNTIME)
@Documented
@Controller
@ResponseBody
public @interface RestController
 */
@RestController
@RequestMapping(value = "/api/hello")
public class HelloController {

    @RequestMapping(value = "/glodon", method = RequestMethod.GET)
    public String helloGlodon() {
        return "hello glodon!!!";
    }

    /*
    GetMapping/PostMapping/PutMapping/DeleteMapping
     */
    @GetMapping(value = "/glodon2")
    public String helloGlodon2() {
        return "hello glodon again !!!";
    }

}

5、运行测试类


更多:

SpringBoot简介

SpringBoot-HelloWorld

spring boot 框架解析

spring boot 部署、启动

spring boot配置文件

spring boot 全局异常捕捉

springboot使用fastjson

springboot使用定时任务、异步

springboot使用AOP

springboot使用拦截器

springboot输出日志

springboot集成hibernate-jpa方式



相关文章: