簡體   English   中英

spring開機上傳文件大小限制

[英]upload file size limit in spring boot

在 2.1.0 版本中,spring.servlet.multipart.max-file-size 屬性無法綁定 org.springframework.util.unit.DataSize。

Property : spring.servlet.multipart.maxFileSize= 50Mb

例外

Description:

Failed to bind properties under 'spring.servlet.multipart.max-file-size' to org.springframework.util.unit.DataSize:

Property: spring.servlet.multipart.maxfilesize
Value: 50Mb
Origin: "spring.servlet.multipart.maxFileSize" from property source "bootstrapProperties"
Reason: failed to convert java.lang.String to @org.springframework.boot.convert.DataSizeUnit org.springframework.util.unit.DataSize

Action:

Update your application's configuration

正如邁克爾斯塔霍斯基提到的

“乙”

必須是資本

Property : spring.servlet.multipart.maxFileSize= 50MB

在 Yaml 中

spring:    
  servlet:
    multipart:
      max-file-size: ${MAX_FILE_SIZE:8MB}
      max-request-size: ${MAX_REQUEST_SIZE:8MB}

今天我重復了這個錯誤,雖然我用大寫的“B”設置了“MB”:

Description:

Failed to bind properties under 'spring.servlet.multipart.max-file-size' to org.springframework.util.unit.DataSize:

    Property: spring.servlet.multipart.max-file-size
    Value: 300MB 
    Origin: class path resource [application.properties]:27:40
    Reason: failed to convert java.lang.String to org.springframework.util.unit.DataSize

如果我注釋掉這個選項應用程序無論如何都不會啟動 - spring 上下文中存在一些錯誤。 所以我認為這是一個錯誤的錯誤消息,然后無法創建上下文 + 給出了多部分選項。

在我的例子中,我在大小末尾有多余的空格(在 MB、KB 之后)。 為了解決這個問題,我刪除了空格。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM