Search in sources :

Example 1 with StandardServletMultipartResolver

use of org.springframework.web.multipart.support.StandardServletMultipartResolver in project spring-boot by spring-projects.

the class MultipartAutoConfiguration method multipartResolver.

@Bean(name = DispatcherServlet.MULTIPART_RESOLVER_BEAN_NAME)
@ConditionalOnMissingBean(MultipartResolver.class)
public StandardServletMultipartResolver multipartResolver() {
    StandardServletMultipartResolver multipartResolver = new StandardServletMultipartResolver();
    multipartResolver.setResolveLazily(this.multipartProperties.isResolveLazily());
    return multipartResolver;
}
Also used : StandardServletMultipartResolver(org.springframework.web.multipart.support.StandardServletMultipartResolver) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with StandardServletMultipartResolver

use of org.springframework.web.multipart.support.StandardServletMultipartResolver in project spring-boot by spring-projects.

the class MultipartAutoConfigurationTests method configureResolveLazily.

@Test
public void configureResolveLazily() {
    this.context = new AnnotationConfigServletWebServerApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context, "spring.http.multipart.resolve-lazily=true");
    this.context.register(WebServerWithNothing.class, BaseConfiguration.class);
    this.context.refresh();
    StandardServletMultipartResolver multipartResolver = this.context.getBean(StandardServletMultipartResolver.class);
    boolean resolveLazily = (Boolean) ReflectionTestUtils.getField(multipartResolver, "resolveLazily");
    assertThat(resolveLazily).isTrue();
}
Also used : AnnotationConfigServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext) StandardServletMultipartResolver(org.springframework.web.multipart.support.StandardServletMultipartResolver) Test(org.junit.Test)

Aggregations

StandardServletMultipartResolver (org.springframework.web.multipart.support.StandardServletMultipartResolver)2 Test (org.junit.Test)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 AnnotationConfigServletWebServerApplicationContext (org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext)1 Bean (org.springframework.context.annotation.Bean)1