文章目录
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.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";
}
}