新建一个最简单的webdemo


结构如下:

步骤

1、pom.xml


  org.springframework.boot
  spring-boot-starter-parent
  2.1.6.RELEASE



  
    org.springframework.boot
    spring-boot-starter-web
  

2、main方法

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class,args);
    }
}

3、controller

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

@RestController
@RequestMapping
public class Democontroller {

    @GetMapping("test01")
    public String test01() {
        return "this is test01 method";
    }
}

4、application.yml

server:
  port: 8080

5、访问地址

http://127.0.0.1:8080/test01

相关