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

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

文章目录
  • 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;

/**
 * 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";
    }
}
成功测试

总结

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

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

新建模块 - maven

继承父类pom.xml
    <parent>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-parentartifactId>
        <version>2.6.7version>
        <relativePath/> 
    parent>
配置依赖

第二个测试依赖可以不要

    <dependencies>
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-webartifactId>
    dependency>
    dependencies>
<dependencies>
     <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-testartifactId>
        <scope>testscope>
    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";
    }
}
成功测试

总结

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/787071.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-05
下一篇2022-05-05

发表评论

登录后才能评论

评论列表(0条)

    保存