Spring Boot FAQ


Swagger 相關

控制台warn提示 Illegal DefaultValue null for parameter type integer java

出現這個問題主要是使用了 ApiModelProperty 注解修飾了非 String 類型的變量,而此時,example 未賦值造成。

    @ApiModelProperty(value = "用戶 id", dataType = "int", example = "1")
    private int id;

上面這種寫法就不會報警告了。

除了上面這種方式,還可以使用如下配置避免看到 warn 的警告:

logging.level.io.swagger.models.parameters.AbstractSerializableParameter=error

PS:example 的值不是簡單的示例值簡單,你不能不符合數據格式的隨便寫寫:

   @ApiModelProperty(notes = "返回數據內容", required = true, example = "[{}...{}]")
    private T data;

上面這種寫法,會報如下錯誤,swagger都無法正常預覽接口:

Errors
Hide
Parser error missed comma between flow collection entries

參考:

slf4j 日志問題

springboot 關於 Class path contains multiple SLF4J bindings.警告的解決


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM