springboot集成swagger
springboot集成swagger
1.添加依赖
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>1.9.6</version>
</dependency>
2.添加配置
import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @Description swagger配置
* WebMvcConfigurationSupport : 配置多个路由同时如果不重写addResourceHandlers方法,启动会报错
* @Author dengfr
* @Date 2022/1/23 下午9:35
* @Version 1.0.0
*/
@EnableSwaggerBootstrapUI
@EnableSwagger2
@Configuration
public class Swagger2Config extends WebMvcConfigurationSupport {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
//为当前包路径,控制器类包
.apis(RequestHandlerSelectors.basePackage("com.dd.xx.controller"))
.paths(PathSelectors.any())
.build();
}
//构建 api文档的详细信息函数
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
//页面标题
.title("XX平台API接口文档")
//创建人
.contact(new Contact("dd","dd","xx@qq,com"))
//版本号
.version("1.0")
//描述
.description("系统API描述")
.build();
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("doc.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
registry.addResourceHandler("/**")
.addResourceLocations("classpath:/static/");
super.addResourceHandlers(registry);
}
}
推荐这些文章:
1.添加pom依赖:
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.10.3</version>
</dependency>
1.创建JWT工具类
...
1导入坐标
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org...
一、pom文件添加引入jar包
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version></dependency><dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-...
在pom.xml里,添加下面这段
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.9</version>
</dependency>
...
在ruoyi-admin的pom.xml里添加kafka的依赖配置,如下:
<!-- kafka 依赖 开始 -->
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
...
spring boot 集成 springfox 3.0.0
springfox 3.0.0 上线之后,调整自己的工程
1. pom中添加依赖
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.0.0</version></dependency><dependency> <groupId>com.alibaba</groupId> <...
Springcloud gateway整合(集成)swagger2+finfe4j踩坑
项目使用gateway代替之前的zuul网关,需要整合swagger,踩了许多坑之后终于解决问题,话不多说直接上代码
因为使用的是阿里的东西所有注册中心选择了nacos,它的配置这里就不贴了
springcloud和boot版本依赖,这是父工程的配置
<properties>
<spring-boot.version>2.1.3.RELEASE</spring-boot.version>
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
&l...
Spring Boot从入门到精通(十一)集成Swagger框架,实现自动生成接口文档
Swagger是一个规范和完整的框架,用于生成、描述、调用和可视化 RESTful 风格的 Web 服务。Swagger 是一组开源项目,其中主要要项目如下:
Swagger-tools:提供各种与Swagger进行集成和交互的工具。例如模式检验
Swagger 1.2文档转换成Swagger 2.0文档等功能。
Swagger-core: 用于Java/Scala的的Swagger实现。与JAX-RS(Jersey、Resteasy、CXF…)、Servlets和Play框架进行集成。
Swagger-js: 用于JavaScript的Swagger实现。
Swagger-node-exp...
SpringBoot 项目集成增强版 Swagger-Knife4j - 附常见问题及解决方案
目录1 - 引入 Maven 依赖2 - 编写 SwaggerConfig 配置类3 - Swagger 常用注解4 - 启动项目后,访问 Swagger 首页出现 Whitelabel Error Page4 - 踩坑指南4.1 Controller 中的接口都没有显示4.2 部分 Controller 中的接口显示不全4.3 页面调试时,提示“xx参数不能为空”参考资料版权声明
1 - 引入 Maven 依赖
👇点这里展开代码👇
<properties>
<spring-boot.version>2.4.3</spring-boot...
springboot集成swagger-ui自动生成API文档
一、添加依赖
<!--swagger-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
...
文章链接:https://www.dianjilingqu.com/50859.html
本文章来源于网络,版权归原作者所有,如果本站文章侵犯了您的权益,请联系我们删除,联系邮箱:saisai#email.cn,感谢支持理解。