idea中搭建Spring boot项目(借助Spring Initializer)

创建新项目

idea中搭建Spring boot项目(借助Spring Initializer)_第1张图片
idea中搭建Spring boot项目(借助Spring Initializer)_第2张图片
idea中搭建Spring boot项目(借助Spring Initializer)_第3张图片

启动端口

在项目配置文件application.properties中写入

    #启动端口
    server.port=8088

idea中搭建Spring boot项目(借助Spring Initializer)_第4张图片

编写测试方法

创建控制类文件夹–>便于规范我们新建一个controller包–>建一个HelloWorld.class

package com.example.hellospringboot.controller;

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

@Controller
@ResponseBody
@RequestMapping("/hey")
public class HelloWorld {
    @RequestMapping("/heyWorld")
    public String heyWorld(){
        return "Hello World";
    }
}

启动测试

运行启动类
idea中搭建Spring boot项目(借助Spring Initializer)_第5张图片
打开浏览器输入http://localhost:8088/hey/heyWorld回车如下
idea中搭建Spring boot项目(借助Spring Initializer)_第6张图片

你可能感兴趣的:(javaweb,spring,intellij-idea,spring,boot)