【问题标题】:Springboot Maven Run Error: Unresolved reference: FileSizeLimitExceededExceptionSpringboot Maven 运行错误:未解决的参考:FileSizeLimitExceededException
【发布时间】:2021-01-16 00:10:00
【问题描述】:

我正在尝试使用 Kotlin 语言运行我的 SpringBoot maven 项目

mvnw spring-boot:run

,但我得到以下错误:

这是我在第 [14,62] 行的代码

import org.apache.tomcat.util.http.fileupload.FileUploadBase.FileSizeLimitExceededException

在 [44,xx] 行

@ExceptionHandler(value = [(FileSizeLimitExceededException::class)]) ==>this is line 44
    @Throws(MultipartException::class)
    fun handleFileSizeLimitExceededException(e: MultipartException, response: HttpServletResponse) {
        response.sendError(HttpStatus.PAYLOAD_TOO_LARGE.value(), "The file exceeds its maximum permitted size.")
    }

我试图找到解决方案,但没有找到任何东西,

我错过了什么吗?我很乐意提供任何帮助。

【问题讨论】:

    标签: java spring-boot maven kotlin


    【解决方案1】:

    application.properties 文件中写下:

    最大文件大小。

    spring.http.multipart.max-file-size=1Mb
    

    最大请求大小。

    spring.http.multipart.max-request-size=10Mb
    

    根据需要设置。

    更新 注意:从 Spring Boot 2 开始,您现在可以这样做

    最大文件大小。

    spring.servlet.multipart.max-file-size=1MB
    

    最大请求大小。

    spring.servlet.multipart.max-request-size=10MB
    

    【讨论】:

    • 感谢您的回复,顺便说一句,当发生错误时,我已经在 application.properties 中设置了它
    猜你喜欢
    • 2019-08-14
    • 1970-01-01
    • 1970-01-01
    • 2020-12-09
    • 2019-01-24
    • 1970-01-01
    • 1970-01-01
    • 2017-08-08
    • 2020-11-24
    相关资源
    最近更新 更多