前言
使用springfox-swagger2 + swagger-bootstrap-ui 升级实现2.7.0->2.10.5,发现高版本的配置方式与低版本配置存在差异,因此记录处理过程文章来源:https://www.toymoban.com/news/detail-410268.html
正文
springfox-swagger 2.7.0 集成方法
maven依赖
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<flatten-maven-plugin.version>1.2.7</flatten-maven-plugin.version>
<maven-source-plugin.version>3.0.1</maven-source-plugin.version>
<spring-boot.version>2.3.2.RELEASE</spring-boot.version>
<!-- swagger2 -->
<springfox-swagger.version>2.7.0</springfox-swagger.version>
<swagger-bootstrap-ui.version>1.9.6</swagger-bootstrap-ui.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-swagger.version}</version>
</dependency>
<!-- swagger2 UI -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-swagger.version}</version>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>${swagger-bootstrap-ui.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
Java Config
@EnableSwagger2
@SpringBootApplication
public class SampleApplication {
public static void main(String[] args) {
SpringApplication.run(SampleApplication.class, args);
}
}
springfox-swagger 2.10.5 集成方法
maven依赖
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<flatten-maven-plugin.version>1.2.7</flatten-maven-plugin.version>
<maven-source-plugin.version>3.0.1</maven-source-plugin.version>
<spring-boot.version>2.3.2.RELEASE</spring-boot.version>
<!-- swagger2 -->
<springfox-swagger.version>2.10.5</springfox-swagger.version>
<swagger-bootstrap-ui.version>1.9.6</swagger-bootstrap-ui.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-swagger.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-spring-webmvc</artifactId>
<version>${springfox-swagger.version}</version>
</dependency>
<!-- swagger2 UI -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-swagger.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>${swagger-bootstrap-ui.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
Java Config
@EnableSwagger2WebMvc
@SpringBootApplication
public class SampleApplication {
public static void main(String[] args) {
SpringApplication.run(SampleApplication.class, args);
}
}
总结
使用springfox-swagger2 + swagger-bootstrap-ui 升级实现2.7.0->2.10.5 需要改造文章来源地址https://www.toymoban.com/news/detail-410268.html
- 升级依赖版本 并补充springfox-spring-webmvc模块
- 注解启动 @EnableSwagger2 修改为@EnableSwagger2WebMvc
到了这里,关于SpringBoot_springfox-swagger版本升级处理的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!