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整合SwaggerSpring BootSwagger
- Swagger+SpringBoot整理SwaggerSpring Boot
- SpringBoot引入WebSocketSpring BootWeb
- SpringBoot_5_integrate_SwaggerSpring BootSwagger
- swagger ui remove springboot pathsSwaggerUIREMSpring Boot
- 07SpringBoot整合SwaggerSpring BootSwagger
- SpringBoot整合Swagger-UISpring BootSwaggerUI
- springboot整合swagger2Spring BootSwagger
- springboot整合swagger遇到的坑Spring BootSwagger
- springboot3.2.3如何整合swaggerSpring BootSwagger
- SpringBoot學習之整合SwaggerSpring BootSwagger
- Swagger基於SpringBoot實現SwaggerSpring Boot
- SpringBoot整合Swagger+Knife4jSpring BootSwagger
- SpringBoot整合Swagger2及使用Spring BootSwagger
- springboot引入mybatis遇到的坑Spring BootMyBatis
- Springboot 引入本地 jar 包方式Spring BootJAR
- Java SpringBoot+Swagger3+Jwt驗證JavaSpring BootSwaggerJWT
- springboot整合swagger實戰(基礎版)Spring BootSwagger
- 三分鐘搞定 Springboot 和Swagger 整合Spring BootSwagger
- Springboot進階-JDBC、Druid、Mybatis、Swagger、SpringMVC、MailSpring BootJDBCUIMyBatisSwaggerSpringMVCAI
- SpringBoot使用Swagger2實現Restful APISpring BootSwaggerRESTAPI
- springboot和swagger2衝突 Swagger-ui/index.html 404 解決Spring BootSwaggerUIIndexHTML
- Springboot整合Swagger2無法正常啟動Spring BootSwagger
- springboot整合swagger。完爆前後端除錯Spring BootSwagger後端除錯
- (九) SpringBoot起飛之路-整合/整合Swagger 2 And 3Spring BootSwagger
- Springboot系列(七) 整合介面文件swagger,使用,測試Spring BootSwagger
- 記錄springboot 3.3.5 版本整合 swagger +spring security + jwtSpring BootSwaggerJWT
- SpringBoot2.6.x及以上版本整合swagger文件Spring BootSwagger
- 企業級SpringBoot教程(十一)springboot整合swagger2,構建Restful APISpring BootSwaggerRESTAPI
- Springboot專案引入druid安裝部署使用Spring BootUI
- SpringBoot整合Swagger2,3分鐘輕鬆入手!Spring BootSwagger
- SpringBoot2.x入門:引入web模組Spring BootWeb
- SpringBoot專案引入Elasticsearch時啟動失敗Spring BootElasticsearch
- .Net Core 3.1瀏覽器後端服務(三) Swagger引入與應用瀏覽器後端Swagger
- [springboot 開發單體web shop] 4. Swagger生成JavadocSpring BootWebSwaggerJava
- Spring Boot2 系列教程(十七)SpringBoot 整合 Swagger2Spring BootSwagger
- SpringBoot2.3.0整合MyBatis-Plus3.4.0和Swagger3.0Spring BootMyBatisS3Swagger