SpringBoot——HelloWorld

  1. 创建Maven项目

  2. pom.xml中加入

        
            org.springframework.boot
            spring-boot-starter-parent
            2.4.1
        
    
        
            
                org.springframework.boot
                spring-boot-starter-web
            
        
    
        
            
                
                    org.springframework.boot
                    spring-boot-maven-plugin
                
            
        

     

  3.  文件目录结构
    SpringBoot——HelloWorld_第1张图片

  4. MainApplication

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

     

  5.  HelloController

    @RestController
    public class HelloController {
    
        @RequestMapping("/")
        public String index(){
            return "Hello, Spring Boot!";
        }
    
    }

     

  6.  运行MainApplication

     

你可能感兴趣的:(SpringBoot)