IDEA 入门 创建SpringBoot

  1. 导入初始化的文件夹
  2. 删除3个目录
    1. .mvn、mvnw、mcnw.cmd
  3. 添加 对web的依赖
  4. 编写 SpringMVC 的 controller。创建文件夹 controller,选中文件夹,复制 HelloController.java
  5. 运行,测试

        <!--对于web的依赖-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

pom.xml

package com.example.demo.controller;

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

@RestController
public class HelloController {
    @RequestMapping(value = "/hello",method = RequestMethod.GET)
    public String helloSpringBoot(){
        return "Hello SpringBoot!";
    }
}

HelloController.java

这里写图片描述
运行

这里写图片描述

运行结果

猜你喜欢

转载自blog.csdn.net/ai_shuyingzhixia/article/details/81698634