联网版
5:http://localhost:8080/books 页面输出打印
官网版
基于SpringBoot官网创建项目,地址:https://start.spring.io/
- 打开SpringBoot官网,选择Quickstart Your Project
- 创建工程,并保存项目
- 解压项目,通过IDE导入项目
.核对内容一致性
引入模块
阿里云版
1.创建新models
2.更改路径url为 http://start.aliyun.com
3.核对内容
4.添加web
图标已更改,引入成功
非联网版
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.4</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
控制器
//Rest模式
@RestController
@RequestMapping("/books")
public class BookController {
@GetMapping
public String getById(){
System.out.println("springboot is running...3");
return "springboot is running...3";
}
}