第一步:引入springdoc-openapi依赖
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.6.0</version>
</dependency>

第二步:
配置OpenApi(新版可以不用配置即可使用,这个是高阶配置)
package cn.ryanfan.virtulab_back.config;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class OpenApiConfig {
@Bean
public OpenAPI openAPI(){
return new OpenAPI()
.info(new Info()
.title("虚拟仿真接口文档")
.description("Desgin By RyanFan")
.contact(new Contact().name("刘一帆")
.email("邮箱").url(""))
.version("v1.0"));
}
//http://localhost:8667/VirtuLab_back/v3/api-docs
//http://localhost:8667/VirtuLab_back/swagger-ui/index.html
}

第三步 :
设置springdoc参数

第四步:
即可使用



第五步:
访问网页版(注意如果出现空白页排除security等的限制)
http://localhost:8667/VirtuLab_back/swagger-ui/index.html#/
