spring boot -- helloworld

1.在idea中创建maven项目


2.在pom.xml中添加依赖

    pom
    
        org.springframework.boot
        spring-boot-starter-parent
        2.3.0.RELEASE
    
    
        
            org.springframework.boot
            spring-boot-starter-web
        
    

3.新建子工程


4.在子工程中创建controller

package com.sfencs.first;


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

@RestController
public class TestController {

    @RequestMapping("hello")
    public String hello() {
        return "hello world";
    }
}

5.创建springboot启动类

package com.sfencs.first;

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

@SpringBootApplication
public class SpringBootApp {

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

6.运行启动类main函数

浏览器输入http://localhost:8080/hello

你可能感兴趣的:(spring boot -- helloworld)