springboot升级到3后之前的knife4j配置就要变了一下了
1.导入依赖
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId><version>4.1.0</version>
</dependency>
2.创建配置文件
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 Knife4jConfig {@Beanpublic OpenAPI springShopOpenAPI() {return new OpenAPI()// 接口文档标题.info(new Info().title("接口文档")// 接口文档简介.description("Knife4j OpenApi3的接口文档")// 接口文档版本.version("v1.0")// 开发者联系方式.contact(new Contact().name("").email("")));}
}
3.controller上注解变了
@Tag(name = "首页")
public class HomeController {
controller方法上的注解
@Operation(summary = "获取xxx")
public Result<xxx> getxxx(){
4.实体类应用的注解也变了
@Data
@Schema(name = "XXX")
public class XXXVO{@Id@Schema(description = "")private Integer id ;/** 父级id */@Schema(description = "父级id")private Integer pid ;
}