Spring Boot Starter Swagger

Introduction to the

Swagger and Spring Boot are now two of the most commonly used frameworks in Java Web development. There are a number of Starter sites on Github that integrate the two (mostly unofficial, they don’t seem to be available), but most of them have more or less the following problems:

  • Integration is low and many functions provided by Springfox-Swagger2 cannot be configured by Spring Boot or are configured in complex ways
  • The project was neglected in maintenance, and many issues were not solved
  • Poor scalability, when the user has some requirements can only pray for the project to update or modify the source code
  • Not compatible with both Spring boot1. x and Spring boot2. x

After searching Github for a long time without finding one, I created my own.

The Starter has the following features:

  • Perfect for Springfox-Swagger2, almost all configuration is supported through YAML files
  • Provides interceptors that allow users to extend their own custom configurations
  • Both Spring BooT1 and Spring Boot2 are supported
  • Extended some small functions, such as displaying current hostname, etc

The project address

How to use

Introduction of depend on

pom.xml

<! -- Spring Boot1 user -->
<dependency>
    <groupId>com.github.taccisum</groupId>
    <artifactId>swagger-spring-boot1-starter</artifactId>
    <version>{lastest.version}</version>
</dependency>

<! -- Spring Boot2 user -->
<dependency>
    <groupId>com.github.taccisum</groupId>
    <artifactId>swagger-spring-boot2-starter</artifactId>
    <version>{lastest.version}</version>
</dependency>
Copy the code

application.yml

swagger:
  base-package: com.github.taccisum.controller
Copy the code

Start the project, open http://localhost:8080/swagger-ui.html can view the API documentation.

More can be found at github.com/taccisum/sp… Understanding.