springboot專案實踐 整合swagger

2021-10-11 23:21:39 字數 2043 閱讀 5176

1.在pom檔案中做如下配置

>

>

io.springfoxgroupid

>

>

springfox-swagger2artifactid

>

>

2.9.2version

>

dependency

>

>

>

io.springfoxgroupid

>

>

springfox-swagger-uiartifactid

>

>

2.9.2version

>

dependency

>

>

>

io.swaggergroupid

>

>

swagger-annotationsartifactid

>

>

1.5.21version

>

dependency

>

>

>

io.swaggergroupid

>

>

swagger-modelsartifactid

>

>

1.5.21version

>

dependency

>

2.swaggerconfig配置檔案內容如下,根據個人特殊要求做修改:

package com.spring.model.configuration;

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.builders.requesthandlerselectors;

import springfox.documentation.service.apiinfo;

import springfox.documentation.spi.documentationtype;

import springfox.documentation.spring.web.plugins.docket;

import springfox.documentation.swagger2.annotations.enableswagger2;

/** * @author:

* @date:

* @explain:

* @description:

*/@configuration

@enableswagger2

public

class

swaggerconfig

private apiinfo apiinfo()

}

在controller上寫如下配置。

@apioperation

("測試請求"

)

測試樣例**如下:

@restcontroller

public

class

testcontroller

}

專案目錄結構如下:

測試執行結果如下:

githup專案位址

Spring Boot專案實踐之問答社群

專案源 已託管在 github,歡迎 star fork。qa是乙個基於 b s 架構而設計開發的社群 主要為使用者提供以下服務 spring boot mybatis mysql redis freemarker 為了保證使用者資訊保安,系統對使用者密碼採用 salt md5 方式進行加密。使用者...

Spring Boot最佳實踐

org.springframework.boot spring boot starter data redis 如果你想使用mongodb,你有 org.springframework.boot spring boot starter data mongodb 依賴於這些starter,依靠這些經過...

實踐問題集

本片文章,記錄開發測試過程中遇到的所有問題。會持續更新。1 使用linux,中途斷電。重新開機遇到這個問題 the root filesystem on dev sda1 requires a manual fsck initramfs 解決方法 其實就是需要我們自己手動使用fsck檢查磁碟 ini...