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

创建新项目



启动端口

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

bash 复制代码
    #启动端口
    server.port=8088

编写测试方法

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

java 复制代码
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";
    }
}

启动测试

运行启动类

打开浏览器输入http://localhost:8088/hey/heyWorld回车如下

相关推荐
zzb15801 天前
RAG from Scratch-优化-query
java·数据库·人工智能·后端·spring·mybatis
J2虾虾1 天前
在SpringBoot中使用Druid
java·spring boot·后端·druid
kuntli1 天前
p命名空间注入原理详解
spring
qwert10371 天前
跨域问题解释及前后端解决方案(SpringBoot)
spring boot·后端·okhttp
yuweiade1 天前
【Spring】Spring MVC案例
java·spring·mvc
码喽7号1 天前
springboot学习四:RESTful风格+swagger
spring boot·学习·restful
beata1 天前
Spring Boot基础-2:Spring Boot 3.x 起步依赖(Starter)深度拆解:为什么引入一个依赖就够了?
spring boot·后端
深蓝轨迹1 天前
SpringBoot YAML配置文件全解析:语法+读取+高级用法
java·spring boot·后端·学习
深蓝轨迹1 天前
乐观锁 vs 悲观锁 含面试模板
java·spring boot·笔记·后端·学习·mysql·面试
Coder_Boy_1 天前
分布式系统核心技术完整梳理(含分库分表、分布式事务、熔断补偿)
jvm·分布式·spring·中间件