基于springboot和mybatis的RealWorld后端项目实战一之hello-springboot

新建Maven项目

注意archetype选择quickstart

pom.xml


修改App.java

App.java同级目录新增controller包

HelloController.java

java 复制代码
package org.example.controller;

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

@RestController
@RequestMapping("hello")
public class HelloController {

    @GetMapping("/show")
    public String sayHello(){
        return "helloworld";
    }
}

启动服务

浏览器输入

复制代码
http://localhost:8080/hello/show
相关推荐
我叫张小白。4 小时前
Spring Boot拦截器详解:实现统一的JWT认证
java·spring boot·web·jwt·拦截器·interceptor
uzong6 小时前
Mermaid: AI 时代画图的魔法工具
后端·架构
q***69777 小时前
Spring Boot与MyBatis
spring boot·后端·mybatis
IUGEI8 小时前
synchronized的工作机制是怎样的?深入解析synchronized底层原理
java·开发语言·后端·c#
间彧8 小时前
GraalVM Native Image:跨平台能力与编译模式深度解析
后端
间彧8 小时前
GraalVM Native Image 与传统 JVM 内存管理:云原生时代的技术选型指南
后端
r***12388 小时前
SpringBoot最佳实践之 - 使用AOP记录操作日志
java·spring boot·后端
b***74888 小时前
前端GraphQL案例
前端·后端·graphql
LSL666_9 小时前
SpringBoot自动配置类
java·spring boot·后端·自动配置类
q***78379 小时前
Spring Boot 3.X:Unable to connect to Redis错误记录
spring boot·redis·后端