首先创建一个maven项目,和创建一个Spring项目一样
在pom文件中引入相关的依赖,依赖是以前引过的
org.springframework.boot spring-boot-starter-parent 2.0.3.RELEASE 4.0.0 springboot-02 war springboot-02 Maven Webapp http://www.example.com UTF-8 UTF-8 1.8 junit junit 4.11 test org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test springboot-02
编写的Controller和SpringBoot一样
package cn.studio.controller;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;/** * Created by mycom on 2018/6/22. */@SpringBootApplication@RestControllerpublic class HelloController { @RequestMapping("/hello") public Object hello(){ return "你好我好"; } public static void main(String[] args) { SpringApplication.run(HelloController.class, args); }}