1.pom.xml依赖配置: ①换一下版本2.1.16.RELEASE。 ②不同版本不同测试依赖,删除版本不同的测试依赖
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.16.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>gua</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>gua</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
2.测试类换成自己的
3.因为SpringBoot默认是自动扫描自己的Application所在包下的路径,所以自己创建一个controller包,然后创建自己的测试controller类
TestController测试类
package com.example.gua.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* zt
* 2020/11/8
* 10:47
*/
@RestController
public class TestController {
@GetMapping("/test")
public String test(){
return "Hello SpringBoot~";
}
}
1.tomcat启动成功
2.浏览器界面显示内容