springboot引入swagger
swagger在模組common下的service_base中,在service_edu中使用
common中引入swagger依賴
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>learn-parent</artifactId>
<groupId>com.learn</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>common</artifactId>
<packaging>pom</packaging>
<modules>
<module>service_base</module>
</modules>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>provided </scope>
</dependency>
<!--mybatis-plus-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<scope>provided </scope>
</dependency>
<!--lombok用來簡化實體類:需要安裝lombok外掛-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided </scope>
</dependency>
<!--swagger-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<scope>provided </scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<scope>provided </scope>
</dependency>
<!-- redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- spring2.X整合redis所需common-pool2
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.6.0</version>
</dependency>-->
</dependencies>
</project>
SwaggerConfig
/*Swagge配置類*/
package com.bigdata.servicebase;
import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
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;
@Configuration//配置類註解
@EnableSwagger2 //swagger註解
public class SwaggerConfig {
@Bean
public Docket webApiConfig(){
return new Docket(DocumentationType.SWAGGER_2)
.groupName("webApi")
.apiInfo(webApiInfo())
.select()
.paths(Predicates.not(PathSelectors.regex("/admin/.*")))
.paths(Predicates.not(PathSelectors.regex("/error.*")))
.build();
}
private ApiInfo webApiInfo(){
return new ApiInfoBuilder()
.title("API文件")
.description("本文件描述了微服務介面定義")
.version("1.0")
.contact(new Contact("java", "http://bdlab.com", "1107168170@qq.com"))
.build();
}
}
引入service_base
<!--在service中引入service_base依賴 使用如swagger-->
<dependency>
<artifactId>service_base</artifactId>
<groupId>com.learn</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
啟動類掃描配置
package com.bigdata.eduservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan(basePackages = ("com.bigdata")) //掃描配置類 swagger
public class EduApplication {
public static void main(String[] args) {
SpringApplication.run(EduApplication.class, args);
}
}
相關文章
- SpringBoot2.6.13版本引入SwaggerSpring BootSwagger
- SpringBoot引入WebSocketSpring BootWeb
- SpringBoot整合SwaggerSpring BootSwagger
- Swagger+SpringBoot整理SwaggerSpring Boot
- SpringBoot_5_integrate_SwaggerSpring BootSwagger
- swagger ui remove springboot pathsSwaggerUIREMSpring Boot
- 07SpringBoot整合SwaggerSpring BootSwagger
- springboot整合swagger2Spring BootSwagger
- SpringBoot整合Swagger-UISpring BootSwaggerUI
- Springboot 引入本地 jar 包方式Spring BootJAR
- springboot引入mybatis遇到的坑Spring BootMyBatis
- SpringBoot學習之整合SwaggerSpring BootSwagger
- springboot整合swagger遇到的坑Spring BootSwagger
- Swagger基於SpringBoot實現SwaggerSpring Boot
- springboot3.2.3如何整合swaggerSpring BootSwagger
- SpringBoot整合Swagger2及使用Spring BootSwagger
- SpringBoot整合Swagger+Knife4jSpring BootSwagger
- springboot整合swagger實戰(基礎版)Spring BootSwagger
- SpringBoot來自Swagger的Restful文件生成Spring BootSwaggerREST
- SpringBoot2.x入門:引入web模組Spring BootWeb
- SpringBoot使用Swagger2實現Restful APISpring BootSwaggerRESTAPI
- 三分鐘搞定 Springboot 和Swagger 整合Spring BootSwagger
- springboot和swagger2衝突 Swagger-ui/index.html 404 解決Spring BootSwaggerUIIndexHTML
- Springboot系列(七) 整合介面文件swagger,使用,測試Spring BootSwagger
- springboot整合swagger。完爆前後端除錯Spring BootSwagger後端除錯
- SpringBoot2.6.x及以上版本整合swagger文件Spring BootSwagger
- (九) SpringBoot起飛之路-整合/整合Swagger 2 And 3Spring BootSwagger
- Springboot整合Swagger2無法正常啟動Spring BootSwagger
- Springboot專案引入druid安裝部署使用Spring BootUI
- .Net Core 3.1瀏覽器後端服務(三) Swagger引入與應用瀏覽器後端Swagger
- 企業級SpringBoot教程(十一)springboot整合swagger2,構建Restful APISpring BootSwaggerRESTAPI
- SpringBoot整合Swagger2,3分鐘輕鬆入手!Spring BootSwagger
- Springboot進階-JDBC、Druid、Mybatis、Swagger、SpringMVC、MailSpring BootJDBCUIMyBatisSwaggerSpringMVCAI
- 記錄springboot 3.3.5 版本整合 swagger +spring security + jwtSpring BootSwaggerJWT
- 為什麼引入SpringBoot依賴不用加版本號Spring Boot
- springboot 專案引入tk或者jpa 訪問報錯Spring Boot
- SpringBoot整合超好用的API視覺化介面工具swaggerSpring BootAPI視覺化Swagger
- 升級 SpringBoot 2.6.x 版本後,Swagger 沒法用了。。。Spring BootSwagger