栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SpringBoot -SpringBoot入门案例-阿里云版 && 纯手工版、无网络版

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SpringBoot -SpringBoot入门案例-阿里云版 && 纯手工版、无网络版

文章目录
  • SpringBoot入门案例-阿里云版
    • 新增模块 - Spring Initializr
    • 随意更改springboot版本
    • 控制类
    • 成功测试
    • 总结
  • SpringBoot入门案例-无网络版-纯手工版
    • 新建模块 - maven
    • 继承父类pom.xml
      • 配置依赖
    • 编写Application入口类
    • 控制类
    • 成功测试
    • 总结

SpringBoot入门案例-阿里云版 新增模块 - Spring Initializr

随意更改springboot版本

控制类
package com.taotao.controller;

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


@SuppressWarnings({"all"})
@RestController
@RequestMapping("/books")
public class BookController {

    @GetMapping
    public String getById(){
        System.out.println("spring boot is running3");
        return "spring boot is running3";
    }
}
成功测试

总结

SpringBoot入门案例-无网络版-纯手工版

条件-需要电脑做过springboot项目

新建模块 - maven

继承父类pom.xml
    
        org.springframework.boot
        spring-boot-starter-parent
        2.6.7
         
    
配置依赖

第二个测试依赖可以不要

    
    
        org.springframework.boot
        spring-boot-starter-web
    
    

     org.springframework.boot
        spring-boot-starter-test
        test
    

编写Application入口类
 package com.taotao;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


@SuppressWarnings({"all"})
@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class);
    }
}

控制类
package com.taotao.controller;

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


@SuppressWarnings({"all"})
@RestController
@RequestMapping("/books")
public class BookController {

    @GetMapping
    public String getById(){
        System.out.println("spring boot is running 4");
        return "spring boot is running 4";
    }
}
成功测试

总结

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/841503.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号