amazon-web-services - 在 ECS 上部署时出现 MultipartException - Spring 1.5.15.RELEASE
问题描述
我正面临一个非常奇怪的行为。我正在将我的 jar 打包到一个容器中以将其部署在 ECS 上,但是,在将max-file-size定义为100M时,我的 application.yaml 似乎没有生效。
奇怪的是,当在本地或通过执行 fat jar 启动应用程序时,它工作得很好。
这是我的application.yaml
spring:
http.multipart:
max-file-size: 100MB
max-request-size: 100MB
Dockerfile
FROM openjdk:8-jre-alpine
ARG JAR_FILE
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-Dspring.profiles.active=prod","-jar","/app.jar"]
AWS 上的错误
{
"timestamp": 1535489967123,
"status": 500,
"error": "Internal Server Error",
"exception": "org.springframework.web.multipart.MultipartException",
"message": "Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (43258070) exceeds the configured maximum (10485760)",
"path": "/fake/path/loader"
}
解决方案
问题主要在于您的 application.yaml 没有正确打包。作为替代方案,您可以按照以下方式为您的 spring jar 使用命令行覆盖:
java -jar your-app.jar --spring.http.multipart.max-file-size=100MB --spring.http.multipart.max-request-size=100MB
或者您可以参考此答案中提到的外部应用程序文件加载: 外部应用程序道具
推荐阅读
- html - 如何在firebase的网站地址中隐藏不必要的子文件夹
- android - 从android设备中删除图像?
- php - Laravel 在应用命名空间外创建模型
- android - 我正在尝试将地图嵌套到 RxJava2 中的过滤器中,这样我就可以删除所有没有正确平台的对象。但是建不起来
- python - 在 Windows 上的本地 DynamoDB 上运行“aws dynamodb describe-table”时出现“[Errno 22] Invalid argument”
- r - 在 ggalluvial 中为 alluvia 添加标签
- c++ - Clang 不编译代码,但 gcc 和 msvc 编译了它
- jenkins - Jhipster CI-CD jenkins 管道的 npm 安装错误
- python-3.x - 为什么我使用 pyinstaller 制作的 exe 需要管理员登录?
- javascript - 如何使用 Sequelize 创建或更新多个表?