使用 IntelliJ IDEA 创建一个SpringBoot项目

1.打开想法,点击创建新项目,选择Spring Initializr

使用 IntelliJ IDEA 创建一个SpringBoot项目

2.点击下一步,填写群和神器

使用 IntelliJ IDEA 创建一个SpringBoot项目

3.选择Web,再选择Web复选框

使用 IntelliJ IDEA 创建一个SpringBoot项目

4.填写项目名称,点击完成

使用 IntelliJ IDEA 创建一个SpringBoot项目

5.打开项目目录,删除以下文件夹和文件

使用 IntelliJ IDEA 创建一个SpringBoot项目

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

使用 IntelliJ IDEA 创建一个SpringBoot项目

9.在地址栏中输入http:// localhost:8080 / hello

使用 IntelliJ IDEA 创建一个SpringBoot项目

转载:https://blog.****.net/u011422624/article/details/72886820