1. 打開idea,點擊創建新項目,選擇Spring Initializr

2. 點擊next,填寫Group和Artifact

3. 選擇Web,再選擇Web復選框

4. 填寫Project name,點擊finish

5. 打開項目目錄,刪除以下文件夾和文件

6. 該類是自動生成的,是程序的入口
package com.example.demo;
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);
}
}
7. 創建HelloSpringboot
package com.example.demo;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@EnableAutoConfiguration
public class HelloSpringboot {
@RequestMapping("/hello")
public String say() {
System.out.println("Hello springboot");
return "hello,this is a springboot demo";
}
}
8. 啟動DemoApplication

9. 在地址欄中輸入http://localhost:8080/hello
