package it.valeriovaudi.documentlibrary;

import org.springframework.beans.factory.config.PlaceholderConfigurerSupport;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.FilterRegistrationBean;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.integration.annotation.IntegrationComponentScan;
import org.springframework.integration.config.EnableIntegration;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.web.multipart.support.MultipartFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@SpringBootApplication
@EnableJms
@EnableIntegration
@IntegrationComponentScan
@PropertySources(value = {
        @PropertySource("classpath:bookService.properties")
})
public class MongoGridFsApplication extends SpringBootServletInitializer {
    public static void main(String[] args) {
        SpringApplication.run(MongoGridFsApplication.class, args);
    }

    @Bean
    public FilterRegistrationBean multipartFilter(){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(new MultipartFilter());
        filterRegistrationBean.addUrlPatterns("/*");
        return filterRegistrationBean;
    }

    @Bean
    public static PlaceholderConfigurerSupport propertyPlaceholderConfigurer() {
        return new PropertySourcesPlaceholderConfigurer();
    }

    @Bean
    public WebMvcConfigurer corsConfigurer() {
            return new WebMvcConfigurerAdapter() {
                @Override
                public void addCorsMappings(CorsRegistry registry) {
                    registry.addMapping("/bookService/**").allowedOrigins("*");
                }
            };
    }
}

@@ -1494,321 +1494,8 @@
  %7D%0A%0A
-    @Bean%0A    public FilterRegistrationBean multipartFilter()%7B%0A        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();%0A        filterRegistrationBean.setFilter(new MultipartFilter());%0A        filterRegistrationBean.addUrlPatterns(%22/*%22);%0A        return filterRegistrationBean;%0A    %7D%0A%0A
     

remove useless filter