idea創建SpringBoot項目


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM