當前使用maven分層開發,其中maven-parent專案下,存在maven-commons和maven-A模塊。當前采用springboot+mybatisplus環境,所需依賴包直接在parent模塊下的pom檔案中直接引入了,請教的問題是,swagger-ui頁面中無法顯示A模塊的物體內容,但卻可以顯示A模塊中controller層的所有請求內容,比較費解,希望能夠得以解決后,在swagger-ui.html中正常顯示物體內容+controller請求內容。
==========================================》
已引入了swagger的依賴
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
commons模塊中配置了swagger
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("同級包下"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("xxx")
.description("xxx")
.version("1.0")
.build();
}
}
commons模塊中僅存在物體類和工具類相關內容,沒有springboot啟動引導類,也沒有yml檔案配置,物體類配置部分
@ApiModelProperty("是否成功")
private boolean flag;
@ApiModelProperty("狀態碼")
private Integer code;
@ApiModelProperty("狀態資訊")
private String message;
@ApiModelProperty("回傳資料")
private Object data;
《======================================
在A模塊中pom檔案參考了commons模塊,撰寫了controller(使用了swagger相關注解), service, dao(mybatis plus),entity(使用了swagger相關注解),訪問測驗A模塊時,會發現在swagger-ui.html頁面中的models中僅存在commons模塊中的物體內容,但是A模塊中的物體內容并沒有展示出來,另外,A模塊中的controller中的每個請求能夠正常展示在swagger-ui.html中,請求一下,A模塊的物體哪里去了?如何能夠保證多模塊之間可以完全共用swagger呢?
uj5u.com熱心網友回復:
大致知道怎么回事了,還是希望有大神過來指導一下。知道如何解決,但不知道如何理解。轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/284271.html
標籤:Java EE
