第一个SpringBoot程序

第一个SpringBoot程序

工具:

  1. jdk1.8
  2. maven 3.6.1
  3. springboot:最新版
  4. IDEA

使用方法

  1. 直接上官网
  2. 在IDEA里创建

注意事项

  1. SpringBootApplication是程序的主入口,不能删除
  2. application.properties核心配置文件
  3. localhost:8080直接启动,显示 /error 显示启动成功(没有文件)
  4. 在DemoApplication同级目录下添加文件夹,编写代码就是这里

代码编写

package com.example.demo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ye xin
 */

@RestController
public class DemoController {

    //接口:http://localhost:8080/hello

    @RequestMapping("/hello")
    public String hello(){
        //调用业务,接受前端参数
        return "hello,world";
    }
}

posted @ 2021-03-04 18:12  不邛  阅读(54)  评论(0)    收藏  举报