zl程序教程

您现在的位置是:首页 >  其他

当前栏目

零基础学习SpringBoot2-写一个HelloWorld

基础学习 一个 HelloWorld SpringBoot2
2023-06-13 09:12:49 时间

简介

Spring Boot来简化Spring应用开发,约定大于配置, 去繁从简。

创建SpringBoot项目

添加依赖

     
     <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

写一个最简单的控制器

package com.lglbc.springbootlearning;

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

@RestController
public class IndexController {
    @RequestMapping("/test")
    public String hello(){
        return "helloWorld";
    }
}

运行项目

测试一波

http://localhost:8080/test

成长心路 | 优质书单 | 面试资料

牛人故事 | 前沿技术 | 视频教程