Spring boot 移动到Spring Boot时,将此代码放在何处?

Spring boot 移动到Spring Boot时,将此代码放在何处?,spring-boot,Spring Boot,我有一个应用程序使用此代码来调整“MultipartConfigElement”: 我想我不会再使用AbstractAnnotationConfigDispatcherServletInitializer,那么我的旧代码应该放在哪里呢?看看这个配置,我相信所有的设置都可以在应用程序.properties中完成 多部分(多部分属性) 1) 如果您依赖于将使用标准值初始化DispatcherServlet的spring boot starter web启动器,则不再需要注册DispatcherSe

我有一个应用程序使用此代码来调整“MultipartConfigElement”:


我想我不会再使用
AbstractAnnotationConfigDispatcherServletInitializer
,那么我的旧代码应该放在哪里呢?

看看这个配置,我相信所有的设置都可以在
应用程序.properties
中完成

多部分(多部分属性) 1) 如果您依赖于将使用标准值初始化DispatcherServlet的
spring boot starter web
启动器,则不再需要注册
DispatcherServlet

2) 关于指定的Servlet应用程序上下文的配置:

@Override
protected Class<?>[] getServletConfigClasses () {
    return new Class<?>[]{ WebConfig.class };
}
3) 关于多部分配置,您可以使用Spring Boot
application.properties设置它:

# MULTIPART (MultipartProperties) #多部分(多部分属性)
spring.servlet.multipart.enabled=true
#是否启用对 多部分上传

spring.servlet.multipart.max file size=5MB
#max file size。价值观可以 使用后缀“MB”或“KB”表示兆字节或千字节, 分别

spring.servlet.multipart.location=${java.io.tmpdir}
档案

这是实际情况

spring.servlet.multipart.enabled=true # Whether to enable support of multipart uploads.
spring.servlet.multipart.file-size-threshold=0 # Threshold after which files are written to disk. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively.
spring.servlet.multipart.location= # Intermediate location of uploaded files.
spring.servlet.multipart.max-file-size=1MB # Max file size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively.
spring.servlet.multipart.max-request-size=10MB # Max request size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively.
spring.servlet.multipart.resolve-lazily=false # Whether to resolve the multipart request lazily at the time of file or parameter access.
@Override
protected Class<?>[] getServletConfigClasses () {
    return new Class<?>[]{ WebConfig.class };
}
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
     ....
}
# MULTIPART (MultipartProperties)