import java.time.LocalTime;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

@Configuration
@EnableWebMvc
@EnableScheduling
@ComponentScan({"ru.web.portal.onlinescheduling"})
public class WebConfig extends WebMvcConfigurerAdapter {

    @Scheduled(fixedDelay = 3000)
    public void time() {
        System.out.printf("%s\n", LocalTime.now());
    }

    public static class MvcWebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {


        @Override
        protected Class<?>[] getRootConfigClasses() {
            return new Class[]{WebConfig.class};
        }

        @Override
        protected Class<?>[] getServletConfigClasses() {
           //return new Class[]{WebConfig.class};
            return null;
        }

        @Override
        protected String[] getServletMappings() {
            return new String[]{"/"};

        }
    }

}
