搭建springboot的helloworld

本文详细介绍如何使用SpringBoot创建一个简单的HelloWorld项目,包括环境搭建、项目创建、代码编写及运行测试等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、前期准备

读者的电脑要先安装Tomcat,jdk,编译器idea(推荐)或者eclipse

2、开始

    1)从spring的官网下载快速开始压缩包,地址:https://start.spring.io/

    2)选择maven,springboot版本,依赖,项目名(如果只是入门测试,可以按照我的来)

         

 2)下载后解压,在编译器中打开解压后的包所在目录;

       点击idea的File-->open-->找到解压后的包打开

        

  3)建立对应的package,(右键选择package)

       

     4)打开testController,编写如下代码

package com.redis_example.demo.controller;

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

@RestController
public class testController {
    @RequestMapping("/hello")
    @ResponseBody
    public String hello(){
        return "hello world";
    }
}

    5)运行项目后,在浏览器中输入localhost:8080/hello

          结果如图

至此,springboot的helloworld完成

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值