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

SpringBoot入门案例-阿里云版

新增模块 - Spring Initializr

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-bMqbiMoZ-1651155574053)(springboot.assets/image-20220428211508752.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-rQ3wc8y0-1651155574055)(springboot.assets/image-20220428211553950.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-FAh9p4Em-1651155574055)(springboot.assets/image-20220428211659930.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ml86aVYP-1651155574055)(springboot.assets/image-20220428211736734.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-N73GVgel-1651155574056)(springboot.assets/image-20220428211808080.png)]

随意更改springboot版本

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-XfSEc2oh-1651155574057)(springboot.assets/image-20220428211935954.png)]

控制类

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;

/**
 * create by 刘鸿涛
 * 2022/4/28 16:39
 */
@SuppressWarnings({"all"})
@RestController
@RequestMapping("/books")
public class BookController {

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

成功测试

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-GLQrKKfI-1651155574058)(springboot.assets/image-20220428215227070.png)]

总结

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-sU9RgG0Z-1651155574059)(springboot.assets/image-20220428215352019.png)]

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

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

新建模块 - maven

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Wf1tgbTi-1651155574060)(springboot.assets/image-20220428215813612.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-sJp5Agvx-1651155574060)(springboot.assets/image-20220428215846074.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-3rygvvw4-1651155574061)(springboot.assets/image-20220428220156605.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-hbDDl8uO-1651155574062)(springboot.assets/image-20220428220301048.png)]

继承父类pom.xml

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.7</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

配置依赖

第二个测试依赖可以不要

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

编写Application入口类

 package com.taotao;

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

/**
 * create by 刘鸿涛
 * 2022/4/28 22:08
 */
@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;

/**
 * create by 刘鸿涛
 * 2022/4/28 16:39
 */
@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";
    }
}

成功测试

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-izRhbj76-1651155574062)(springboot.assets/image-20220428221627977.png)]

总结

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-sfIE9CUT-1651155574062)(springboot.assets/image-20220428221753363.png)]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

鬼鬼骑士

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值