问:
Spring boot - ServletContext is required
i'm building a simple Spring boot + Hibernate application but i cannot make it start...

I'm getting this exception

```<code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultServletHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'defaultServletHandlerMapping' threw exception; nested exception is java.lang.IllegalArgumentException: ServletContext is required
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:296) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
    at it.besmart.epark.config.Application.main(Application.java:18) [classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.5.8.RELEASE.jar:1.5.8.RELEASE]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultServletHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'defaultServletHandlerMapping' threw exception; nested exception is java.lang.IllegalArgumentException: ServletContext is required
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    ... 25 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultServletHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'defaultServletHandlerMapping' threw exception; nested exception is java.lang.IllegalArgumentException: ServletContext is required
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:519) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1194) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:310) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.web.servlet.handler.HandlerMappingIntrospector.initHandlerMappings(HandlerMappingIntrospector.java:108) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.web.servlet.handler.HandlerMappingIntrospector.<init>(HandlerMappingIntrospector.java:82) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.security.config.annotation.web.configurers.CorsConfigurer$MvcCorsFilter.getMvcCorsFilter(CorsConfigurer.java:109) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.web.configurers.CorsConfigurer$MvcCorsFilter.access$000(CorsConfigurer.java:101) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.web.configurers.CorsConfigurer.getCorsFilter(CorsConfigurer.java:96) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.web.configurers.CorsConfigurer.configure(CorsConfigurer.java:65) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.web.configurers.CorsConfigurer.configure(CorsConfigurer.java:38) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder.configure(AbstractConfiguredSecurityBuilder.java:384) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder.doBuild(AbstractConfiguredSecurityBuilder.java:330) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.AbstractSecurityBuilder.build(AbstractSecurityBuilder.java:41) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.web.builders.WebSecurity.performBuild(WebSecurity.java:290) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.web.builders.WebSecurity.performBuild(WebSecurity.java:77) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder.doBuild(AbstractConfiguredSecurityBuilder.java:334) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.AbstractSecurityBuilder.build(AbstractSecurityBuilder.java:41) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.springSecurityFilterChain(WebSecurityConfiguration.java:104) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$6ecba43.CGLIB$springSecurityFilterChain$2(<generated>) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$6ecba43$$FastClassBySpringCGLIB$$1b0412c7.invoke(<generated>) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$6ecba43.springSecurityFilterChain(<generated>) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    ... 26 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'defaultServletHandlerMapping' threw exception; nested exception is java.lang.IllegalArgumentException: ServletContext is required
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    ... 62 common frames omitted
Caused by: java.lang.IllegalArgumentException: ServletContext is required
    at org.springframework.util.Assert.notNull(Assert.java:134) ~[spring-core-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer.<init>(DefaultServletHandlerConfigurer.java:55) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.defaultServletHandlerMapping(WebMvcConfigurationSupport.java:491) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$b6e92f59.CGLIB$defaultServletHandlerMapping$41(<generated>) ~[spring-boot-autoconfigure-1.5.8.RELEASE.jar:1.5.8.RELEASE]
    at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$b6e92f59$$FastClassBySpringCGLIB$$ef94a235.invoke(<generated>) ~[spring-boot-autoconfigure-1.5.8.RELEASE.jar:1.5.8.RELEASE]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$b6e92f59.defaultServletHandlerMapping(<generated>) ~[spring-boot-autoconfigure-1.5.8.RELEASE.jar:1.5.8.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    ... 63 common frames omitted
</code>```

My configuration files are

Application.java

```<code>@EnableScheduling
@SpringBootApplication
@EnableAsync
@ComponentScan("it.besmart.epark")
public class Application extends SpringBootServletInitializer{

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
</code>```

then a HibernateConfiguration

```<code>@Configuration
@EnableTransactionManagement
@ComponentScan({ "it.besmart.epark.persistence" })
@PropertySource(value = { "classpath:application.properties" })
public class HibernateConfiguration {

@Autowired
private Environment environment;

@Bean
public LocalSessionFactoryBean sessionfactory(){
    LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
    sessionFactory.setDataSource(dataSource());
    sessionFactory.setPackagesToScan(new String[] {"it.besmart.epark.persistence.model"});
    sessionFactory.setHibernateProperties(hibernateProperties());
    return sessionFactory;
}

@Bean
public DataSource dataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName(environment.getRequiredProperty("jdbc.driverClassName"));
    dataSource.setUrl(environment.getRequiredProperty("jdbc.url"));
    dataSource.setUsername(environment.getRequiredProperty("jdbc.username"));
    dataSource.setPassword(environment.getRequiredProperty("jdbc.password"));
    return dataSource;
}

private Properties hibernateProperties() {
    Properties properties = new Properties();
    properties.put("hibernate.dialect", environment.getRequiredProperty("hibernate.dialect"));
    properties.put("hibernate.show_sql", environment.getRequiredProperty("hibernate.show_sql"));
    properties.put("hibernate.format_sql", environment.getRequiredProperty("hibernate.format_sql"));
    return properties;
}

@Bean
@Autowired
public HibernateTransactionManager transactionManager(SessionFactory s) {
   HibernateTransactionManager txManager = new HibernateTransactionManager();
   txManager.setSessionFactory(s);
   return txManager;
}
}
</code>```

And the SecurityConfiguration

```<code>@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Autowired
    @Qualifier("customUserDetailsService")
    UserDetailsService userDetailsService;

    @Autowired
    CustomSuccessHandler customSuccessHandler;

    @Autowired
    DataSource dataSource;

    @Autowired
    public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception {
        auth.userDetailsService(userDetailsService);
        auth.authenticationProvider(authenticationProvider());
    }

    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }

    @Bean
    public DaoAuthenticationProvider authenticationProvider() {
        DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
        authenticationProvider.setUserDetailsService(userDetailsService);
        authenticationProvider.setPasswordEncoder(passwordEncoder());
        return authenticationProvider;
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers("/", "/home", "/spots/**", "/parks/**", "/floors/**", "/lights/**", "/sensors/**",
                        "/illumination/**", "/occupation/**", "/movement/**", "/map/**", "/include/**", "/energy/**")
                .access("hasRole('USER') or hasRole('ADMIN')").antMatchers("/admin/**").access("hasRole('ADMIN')")
                .antMatchers("/user/**", "/updatePassword")
                .hasAuthority("CHANGE_PASSWORD_PRIVILEGE").

                and().formLogin().loginPage("/login").successHandler(customSuccessHandler).usernameParameter("email")
                .passwordParameter("password").and().rememberMe().rememberMeParameter("remember-me")
                .tokenRepository(persistentTokenRepository()).tokenValiditySeconds(86400).and().csrf().and()
                .exceptionHandling().accessDeniedPage("/Access_Denied");

    }

    @Bean
    public PersistentTokenRepository persistentTokenRepository() {
        JdbcTokenRepositoryImpl tokenRepositoryImpl = new JdbcTokenRepositoryImpl();
        tokenRepositoryImpl.setDataSource(dataSource);
        return tokenRepositoryImpl;
    }

    @Bean
    public RequestDataValueProcessor requestDataValueProcessor() {
        return new CsrfRequestDataValueProcessor();
    }

}
</code>```

And last the WebConfig.java

```<code>@Configuration
@ComponentScan("it.besmart.epark")
public class WebConfig extends WebMvcConfigurerAdapter{

    @Autowired
    RoleToUserProfileConverter roleToUserProfileConverter;

    @Autowired
    ManagedParksToParksConverter managedParksToParkConverter;

    public WebConfig(){
        super();
    }

    @Bean
    public MessageSource messageSource() {
        ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
        messageSource.setBasename("classpath:messages");
        messageSource.setDefaultEncoding("UTF-8");

        return messageSource;
    }

    @Bean
    public ViewResolver getCsvViewResolver(){

        ResourceBundleViewResolver resolver = new ResourceBundleViewResolver();
        resolver.setBasename("views");
        resolver.setOrder(1);

        return resolver;
    }

    @Override
    public void addFormatters(FormatterRegistry registry) {
        registry.addConverter(roleToUserProfileConverter);
        registry.addConverter(managedParksToParkConverter);

    }

    @Bean(name = "multipartResolver")
    public StandardServletMultipartResolver resolver() {
        return new StandardServletMultipartResolver();
    }

    @Bean
    public LocaleResolver localeResolver(){
    CookieLocaleResolver resolver = new CookieLocaleResolver();
    resolver.setDefaultLocale(new Locale("it"));

    resolver.setCookieName("smartparklocale");
    resolver.setCookieMaxAge(9600);
    return resolver;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
    LocaleChangeInterceptor interceptor = new LocaleChangeInterceptor();
    interceptor.setParamName("language");
    registry.addInterceptor(interceptor);
    }

}
</code>```

I don't know why the Servlet it's not created since i extend the main class with the SpringBootServletInitializer which usually in other application works well... i'm using Spring Boot 1.5.8.RELEASE

答:
Have you forgotten to add a dependency in maven/gradle for security:
spring-boot-starter-security?</p>

Body:
i'm building a simple Spring boot + Hibernate application but i cannot make it start...

I'm getting this exception

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultServletHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'defaultServletHandlerMapping' threw exception; nested exception is java.lang.IllegalArgumentException: ServletContext is required
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:296) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
    at it.besmart.epark.config.Application.main(Application.java:18) [classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.5.8.RELEASE.jar:1.5.8.RELEASE]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultServletHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'defaultServletHandlerMapping' threw exception; nested exception is java.lang.IllegalArgumentException: ServletContext is required
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    ... 25 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultServletHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'defaultServletHandlerMapping' threw exception; nested exception is java.lang.IllegalArgumentException: ServletContext is required
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:519) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1194) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:310) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.web.servlet.handler.HandlerMappingIntrospector.initHandlerMappings(HandlerMappingIntrospector.java:108) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.web.servlet.handler.HandlerMappingIntrospector.<init>(HandlerMappingIntrospector.java:82) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.security.config.annotation.web.configurers.CorsConfigurer$MvcCorsFilter.getMvcCorsFilter(CorsConfigurer.java:109) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.web.configurers.CorsConfigurer$MvcCorsFilter.access$000(CorsConfigurer.java:101) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.web.configurers.CorsConfigurer.getCorsFilter(CorsConfigurer.java:96) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.web.configurers.CorsConfigurer.configure(CorsConfigurer.java:65) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.web.configurers.CorsConfigurer.configure(CorsConfigurer.java:38) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder.configure(AbstractConfiguredSecurityBuilder.java:384) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder.doBuild(AbstractConfiguredSecurityBuilder.java:330) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.AbstractSecurityBuilder.build(AbstractSecurityBuilder.java:41) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.web.builders.WebSecurity.performBuild(WebSecurity.java:290) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.web.builders.WebSecurity.performBuild(WebSecurity.java:77) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder.doBuild(AbstractConfiguredSecurityBuilder.java:334) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.AbstractSecurityBuilder.build(AbstractSecurityBuilder.java:41) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.springSecurityFilterChain(WebSecurityConfiguration.java:104) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$6ecba43.CGLIB$springSecurityFilterChain$2(<generated>) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$6ecba43$$FastClassBySpringCGLIB$$1b0412c7.invoke(<generated>) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$6ecba43.springSecurityFilterChain(<generated>) ~[spring-security-config-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    ... 26 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'defaultServletHandlerMapping' threw exception; nested exception is java.lang.IllegalArgumentException: ServletContext is required
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    ... 62 common frames omitted
Caused by: java.lang.IllegalArgumentException: ServletContext is required
    at org.springframework.util.Assert.notNull(Assert.java:134) ~[spring-core-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer.<init>(DefaultServletHandlerConfigurer.java:55) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.defaultServletHandlerMapping(WebMvcConfigurationSupport.java:491) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$b6e92f59.CGLIB$defaultServletHandlerMapping$41(<generated>) ~[spring-boot-autoconfigure-1.5.8.RELEASE.jar:1.5.8.RELEASE]
    at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$b6e92f59$$FastClassBySpringCGLIB$$ef94a235.invoke(<generated>) ~[spring-boot-autoconfigure-1.5.8.RELEASE.jar:1.5.8.RELEASE]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$b6e92f59.defaultServletHandlerMapping(<generated>) ~[spring-boot-autoconfigure-1.5.8.RELEASE.jar:1.5.8.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    ... 63 common frames omitted

My configuration files are

Application.java

@EnableScheduling
@SpringBootApplication
@EnableAsync
@ComponentScan("it.besmart.epark")
public class Application extends SpringBootServletInitializer{

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

then a HibernateConfiguration

@Configuration
@EnableTransactionManagement
@ComponentScan({ "it.besmart.epark.persistence" })
@PropertySource(value = { "classpath:application.properties" })
public class HibernateConfiguration {

@Autowired
private Environment environment;

@Bean
public LocalSessionFactoryBean sessionfactory(){
    LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
    sessionFactory.setDataSource(dataSource());
    sessionFactory.setPackagesToScan(new String[] {"it.besmart.epark.persistence.model"});
    sessionFactory.setHibernateProperties(hibernateProperties());
    return sessionFactory;
}

@Bean
public DataSource dataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName(environment.getRequiredProperty("jdbc.driverClassName"));
    dataSource.setUrl(environment.getRequiredProperty("jdbc.url"));
    dataSource.setUsername(environment.getRequiredProperty("jdbc.username"));
    dataSource.setPassword(environment.getRequiredProperty("jdbc.password"));
    return dataSource;
}

private Properties hibernateProperties() {
    Properties properties = new Properties();
    properties.put("hibernate.dialect", environment.getRequiredProperty("hibernate.dialect"));
    properties.put("hibernate.show_sql", environment.getRequiredProperty("hibernate.show_sql"));
    properties.put("hibernate.format_sql", environment.getRequiredProperty("hibernate.format_sql"));
    return properties;
}

@Bean
@Autowired
public HibernateTransactionManager transactionManager(SessionFactory s) {
   HibernateTransactionManager txManager = new HibernateTransactionManager();
   txManager.setSessionFactory(s);
   return txManager;
}
}

And the SecurityConfiguration

@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Autowired
    @Qualifier("customUserDetailsService")
    UserDetailsService userDetailsService;

    @Autowired
    CustomSuccessHandler customSuccessHandler;

    @Autowired
    DataSource dataSource;

    @Autowired
    public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception {
        auth.userDetailsService(userDetailsService);
        auth.authenticationProvider(authenticationProvider());
    }

    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }

    @Bean
    public DaoAuthenticationProvider authenticationProvider() {
        DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
        authenticationProvider.setUserDetailsService(userDetailsService);
        authenticationProvider.setPasswordEncoder(passwordEncoder());
        return authenticationProvider;
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers("/", "/home", "/spots/**", "/parks/**", "/floors/**", "/lights/**", "/sensors/**",
                        "/illumination/**", "/occupation/**", "/movement/**", "/map/**", "/include/**", "/energy/**")
                .access("hasRole('USER') or hasRole('ADMIN')").antMatchers("/admin/**").access("hasRole('ADMIN')")
                .antMatchers("/user/**", "/updatePassword")
                .hasAuthority("CHANGE_PASSWORD_PRIVILEGE").

                and().formLogin().loginPage("/login").successHandler(customSuccessHandler).usernameParameter("email")
                .passwordParameter("password").and().rememberMe().rememberMeParameter("remember-me")
                .tokenRepository(persistentTokenRepository()).tokenValiditySeconds(86400).and().csrf().and()
                .exceptionHandling().accessDeniedPage("/Access_Denied");

    }

    @Bean
    public PersistentTokenRepository persistentTokenRepository() {
        JdbcTokenRepositoryImpl tokenRepositoryImpl = new JdbcTokenRepositoryImpl();
        tokenRepositoryImpl.setDataSource(dataSource);
        return tokenRepositoryImpl;
    }

    @Bean
    public RequestDataValueProcessor requestDataValueProcessor() {
        return new CsrfRequestDataValueProcessor();
    }

}

And last the WebConfig.java

@Configuration
@ComponentScan("it.besmart.epark")
public class WebConfig extends WebMvcConfigurerAdapter{

    @Autowired
    RoleToUserProfileConverter roleToUserProfileConverter;

    @Autowired
    ManagedParksToParksConverter managedParksToParkConverter;

    public WebConfig(){
        super();
    }

    @Bean
    public MessageSource messageSource() {
        ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
        messageSource.setBasename("classpath:messages");
        messageSource.setDefaultEncoding("UTF-8");

        return messageSource;
    }

    @Bean
    public ViewResolver getCsvViewResolver(){

        ResourceBundleViewResolver resolver = new ResourceBundleViewResolver();
        resolver.setBasename("views");
        resolver.setOrder(1);

        return resolver;
    }

    @Override
    public void addFormatters(FormatterRegistry registry) {
        registry.addConverter(roleToUserProfileConverter);
        registry.addConverter(managedParksToParkConverter);

    }

    @Bean(name = "multipartResolver")
    public StandardServletMultipartResolver resolver() {
        return new StandardServletMultipartResolver();
    }

    @Bean
    public LocaleResolver localeResolver(){
    CookieLocaleResolver resolver = new CookieLocaleResolver();
    resolver.setDefaultLocale(new Locale("it"));

    resolver.setCookieName("smartparklocale");
    resolver.setCookieMaxAge(9600);
    return resolver;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
    LocaleChangeInterceptor interceptor = new LocaleChangeInterceptor();
    interceptor.setParamName("language");
    registry.addInterceptor(interceptor);
    }

}

I don't know why the Servlet it's not created since i extend the main class with the SpringBootServletInitializer which usually in other application works well... i'm using Spring Boot 1.5.8.RELEASE


来源: stackexchange

问:
Filtered HTML list: making li elements initially invisible
This is the HTML:

```<code><input type="text" id="myInput" onkeyup="myFunction()" placeholder="orasul tau..">

<ul id="myUL">
    <li>Bucuresti</li>
    <li>Cluj</li>
    <li>Timisoara</li>
</ul>
</code>```

And this is my scipt:

```<code>var value = $('#myInput').val();
if(value.length == 0) {
    $("#myUL li").style.display = "none";
}

$('#myInput').bind('keyup', function() {
    var searchString = $(this).val();
    $("ul li").each(function(index, value) {
        currentName = $(value).text()
        if( currentName.toUpperCase().indexOf(searchString.toUpperCase()) > -1) {
           $(value).show();
        } else {
            $(value).hide();
        }
    });
});
</code>```

I want to filter the elements of the ul based on the text in the input.

Everything is working perfectly without that initial if statement, but I want all the li elements to initially have diplay:none. Adding that if deactivates the whole filtering. Any possible solution for how I could do that?

Any help would be appreciated.

答:
https://jsfiddle.net/Lmhw3u5n/1/

js

```<code>    var value = $('#myInput').val();
//if(value.length == 0) {
    //$("#myUL li").style.display = "none";
//}

$('#myInput').bind('keyup', function() {
    var searchString = $(this).val();
    if(searchString == '') {
        document.getElementById('myUL').style.display = 'none';
    }
    else {
        document.getElementById('myUL').style.display = 'block';
    }
    $("ul li").each(function(index, value) {
        currentName = $(value).text()
        if( currentName.toUpperCase().indexOf(searchString.toUpperCase()) > -1) {
           $(value).show();
        } else {
            $(value).hide();
        }
    });
});
</code>```

ContentLicense: CC BY-SA 3.0

Body:
This is the HTML:

<input type="text" id="myInput" onkeyup="myFunction()" placeholder="orasul tau..">

Bucuresti

Cluj

Timisoara

And this is my scipt:

var value = $('#myInput').val();
if(value.length == 0) {
    $("#myUL li").style.display = "none";
}

$('#myInput').bind('keyup', function() {
    var searchString = $(this).val();
    $("ul li").each(function(index, value) {
        currentName = $(value).text()
        if( currentName.toUpperCase().indexOf(searchString.toUpperCase()) > -1) {
           $(value).show();
        } else {
            $(value).hide();
        }
    });
});

I want to filter the elements of the ul based on the text in the input.

Everything is working perfectly without that initial if statement, but I want all the li elements to initially have diplay:none. Adding that if deactivates the whole filtering. Any possible solution for how I could do that?

Any help would be appreciated.

Body:
https://jsfiddle.net/Lmhw3u5n/1/

js

    var value = $('#myInput').val();
//if(value.length == 0) {
    //$("#myUL li").style.display = "none";
//}

$('#myInput').bind('keyup', function() {
    var searchString = $(this).val();
    if(searchString == '') {
        document.getElementById('myUL').style.display = 'none';
    }
    else {
        document.getElementById('myUL').style.display = 'block';
    }
    $("ul li").each(function(index, value) {
        currentName = $(value).text()
        if( currentName.toUpperCase().indexOf(searchString.toUpperCase()) > -1) {
           $(value).show();
        } else {
            $(value).hide();
        }
    });
});


问:
VBA USERFORM: PREVENT COMBOBOX ESCAPE ON KEYDOWN
Community,

There is a way to prevent an active combobox from losing its focus when hitting the down arrow (or up arrow) when at the end (or start) of a list. If there is a better way to do this (preferably with an MS standard property) please share.

Problem: When at the end of a list in a ComboBox, if you hit the down arrow it will move you to whatever control is physically below the active combobox. Vice versa for being at the top of a combobox and hitting the up arrow. This is sloppy and counterproductive. MS Excel 2013.

Solution: To prevent this lost focus, in the userform's ComboBox code you can enter the following:

```<code>Private Sub Item1_DropDown_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)

Select Case KeyCode
    Case vbKeyDown
        If Item1_DropDown.ListIndex = Item1_DropDown.ListCount - 1 Then
            Item1_DropDown.ListIndex = Item1_DropDown.ListIndex - 1 'when at the bottom, stay in active combobox
        Else: Item1_DropDown.ListIndex = Item1_DropDown.ListIndex 'if not at the bottom, keep moving down
        End If
    Case vbKeyUp
        If Item1_DropDown.ListIndex = 0 Then 'when at the top, stay in active combobox
            Item1_DropDown.ListIndex = 1
        Else:   Item1_DropDown.ListIndex = Item1_DropDown.ListIndex 'if not at the top, keep moving up
        End If
End Select
      ' where "Item1_DropDown" is the name of my combobox
End Sub
</code>```

Okay, that's how I've been able to prevent the combobox from switching to a different control when hitting down/up when at the bottom/top of a ComboBox list.

Does anyone know of a cleaner way to do this? Maybe a way to do this without using code?

答: I tried this last suggestion and it worked perfectly, after I replaced "MSForms.Label" with "MSForms.ComboBox".</p>

Body:
Community,

There is a way to prevent an active combobox from losing its focus when hitting the down arrow (or up arrow) when at the end (or start) of a list. If there is a better way to do this (preferably with an MS standard property) please share.

Problem: When at the end of a list in a ComboBox, if you hit the down arrow it will move you to whatever control is physically below the active combobox. Vice versa for being at the top of a combobox and hitting the up arrow. This is sloppy and counterproductive. MS Excel 2013.

Solution: To prevent this lost focus, in the userform's ComboBox code you can enter the following:

Private Sub Item1_DropDown_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)

Select Case KeyCode
    Case vbKeyDown
        If Item1_DropDown.ListIndex = Item1_DropDown.ListCount - 1 Then
            Item1_DropDown.ListIndex = Item1_DropDown.ListIndex - 1 'when at the bottom, stay in active combobox
        Else: Item1_DropDown.ListIndex = Item1_DropDown.ListIndex 'if not at the bottom, keep moving down
        End If
    Case vbKeyUp
        If Item1_DropDown.ListIndex = 0 Then 'when at the top, stay in active combobox
            Item1_DropDown.ListIndex = 1
        Else:   Item1_DropDown.ListIndex = Item1_DropDown.ListIndex 'if not at the top, keep moving up
        End If
End Select
      ' where "Item1_DropDown" is the name of my combobox
End Sub

Okay, that's how I've been able to prevent the combobox from switching to a different control when hitting down/up when at the bottom/top of a ComboBox list.

Does anyone know of a cleaner way to do this? Maybe a way to do this without using code?


问:
predicate filter rxjava2 - How to pass dynamic filter arguments
I have built some basic filter with rxjava2 which works as expected. I was wondering how I could pass values/pass arguments to the filter (return td.getTypeId() == **<value>**;).  Also if somebody has ideas/clues/examples on how to build a (semi-)dynamic query (Object.<field> == <value>) with rxjava2 / filter that would be appreciated.

```<code>Predicate<TradeDetailed> testfilter;

Flowable<List<TradeDetailed>> td = tr.getTradesDetailedFlowable();

testfilter = new Predicate<TradeDetailed>() {
    @Override
    public boolean test(@NonNull TradeDetailed td) throws Exception {
        return td.getTypeId() == 0;
    }
};

Disposable d = td
        .flatMapIterable(e -> e)
        .filter(e-> testfilter.test(e))
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(t -> {
                        System.out.println("filtered "+t.getReference()));

                    },
                    err -> {
                        System.out.println("error");
                    }
        );
</code>```

答:
you can create a separate class for the Predicate:

```<code>class YourPredicate implements Predicate<TradeDetailed>(){

    private final int compareAgainst;

    public YourPredicate(int compareAgainst){
        this.compareAgainst = compareAgainst;
    }

    @Override
    public boolean test(@NonNull TradeDetailed td) throws Exception {
        return td.getTypeId() == compareAgainst;
    }

}
</code>```

Body:
I have built some basic filter with rxjava2 which works as expected. I was wondering how I could pass values/pass arguments to the filter (return td.getTypeId() == **<value>**;).  Also if somebody has ideas/clues/examples on how to build a (semi-)dynamic query (Object.<field> == <value>) with rxjava2 / filter that would be appreciated.

Predicate<TradeDetailed> testfilter;

Flowable<List<TradeDetailed>> td = tr.getTradesDetailedFlowable();

testfilter = new Predicate<TradeDetailed>() {
    @Override
    public boolean test(@NonNull TradeDetailed td) throws Exception {
        return td.getTypeId() == 0;
    }
};

Disposable d = td
        .flatMapIterable(e -> e)
        .filter(e-> testfilter.test(e))
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(t -> {
                        System.out.println("filtered "+t.getReference()));

                    },
                    err -> {
                        System.out.println("error");
                    }
        );

Body:
you can create a separate class for the Predicate:

class YourPredicate implements Predicate<TradeDetailed>(){

    private final int compareAgainst;

    public YourPredicate(int compareAgainst){
        this.compareAgainst = compareAgainst;
    }

    @Override
    public boolean test(@NonNull TradeDetailed td) throws Exception {
        return td.getTypeId() == compareAgainst;
    }

}


问:
C# rounding differently depending on platform?
I have this tiny piece of code

```<code>double s = -2.6114289999999998;
double s7 = Math.Round(s, 7);
double s5 = Math.Round(s, 5);
double s6 = Math.Round(s, 6);
</code>```

With Platform = Any CPU, I get

```<code>s7: -2.611429
s5: -2.61143
s6: -2.611429
</code>```

With Platform = x64, I get

```<code>s7: -2.6114289999999998
s5: -2.61143
s6: -2.6114289999999998
</code>```

Why? (Output copied from VS's Locals window)

The whole piece of code is:

```<code>    private void btnAlign_Click(object sender, EventArgs e)
    {
        double s = -2.6114289999999998;
        double s7 = Math.Round(s, 7);
        double s5 = Math.Round(s, 5);
        double s6 = Math.Round(s, 6);
    }
</code>```

答:
According to the CSharp language specification 3.0 the following might be the case:

See chapter 4.1.6 at the specification for more information

Floating-point operations may be performed with higher precision than the result type of the operation. For example, some hardware architectures support an “extended” or “long double” floating-point type with greater range and precision than the double type, and implicitly perform all floating-point operations using this higher precision type. Only at excessive cost in performance can such hardware architectures be made to perform floating-point operations with less precision, and rather than require an implementation to forfeit both performance and precision, C# allows a higher precision type to be used for all floating-point operations. Other than delivering more precise results, this rarely has any measurable effects. However, in expressions of the form x * y / z, where the multiplication produces a result that is outside the double range, but the subsequent division brings the temporary result back into the double range, the fact that the expression is evaluated in a higher range format may cause a finite result to be produced instead of an infinity.

In short: The C# spec actually states that hardware architectures may have some impact on floating point types (Double, Float).

The language specification as .doc can be found here.

Body:
I have this tiny piece of code

double s = -2.6114289999999998;
double s7 = Math.Round(s, 7);
double s5 = Math.Round(s, 5);
double s6 = Math.Round(s, 6);

With Platform = Any CPU, I get

s7: -2.611429
s5: -2.61143
s6: -2.611429

With Platform = x64, I get

s7: -2.6114289999999998
s5: -2.61143
s6: -2.6114289999999998

Why? (Output copied from VS's Locals window)

The whole piece of code is:

    private void btnAlign_Click(object sender, EventArgs e)
    {
        double s = -2.6114289999999998;
        double s7 = Math.Round(s, 7);
        double s5 = Math.Round(s, 5);
        double s6 = Math.Round(s, 6);
    }


问:
How to export two DataTables in just one PDF file
I'm currently using DataTables to draw tables in a webpage. I have a table which is not hidden and users can view it without problems. On the other hand, I have a hidden table which has to be exported with the not hidden table at same time.

I want to be able to click on "Export PDF" in the not hidden table and generate a PDF file with both tables, the hidden and the not hidden table.

Could someone help me? I'm a little confused about how to do that.

答:
I havn't tried this but you could attempt to simply trigger the second button from the first.

```<code>$("#foo .buttons-pdf").on("click", function() {
  $("#bar .buttons-pdf").trigger("click");
});
</code>```

The second table will still need to be available in the DOM.

Body:
I havn't tried this but you could attempt to simply trigger the second button from the first.

$("#foo .buttons-pdf").on("click", function() {
  $("#bar .buttons-pdf").trigger("click");
});

The second table will still need to be available in the DOM.


问:
Nested mocked method is not getting called in Mockito
let's assume I have this simple scenario.

```<code>package kivoxdaemon.utils;

import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;

public class TempTest {

   @Test
   public void test() {

      TestMock testMock = Mockito.mock(TestMock.class);

      Mockito.doCallRealMethod().when(testMock).method1();

      Mockito.doAnswer(new Answer() {
         @Override
         public Object answer(InvocationOnMock invocation) throws Throwable {
            System.out.println("Mock method3");
            return null;
         }
      }).when(testMock).method3();

      testMock.method1();
   }

}

class TestMock {

   void method1() {
      System.out.println("method1");
      method2();
   }

   private void method2() {
      System.out.println("method2");
      method3();
   }

   void method3() {
      System.out.println("method3");
   }
}
</code>```

This code has the following output in console:

method1

method2

method3

whereas I would expect it to be

method1

method2

Mock method3

Method 3 is mocked, so why isn't it getting called?

Can you please suggest how to implement such I believe very common scenario, when the call chain starts from a real public method, but some other methods, called internally, have to be mocked?

Thank you in advance.

UPD: Just figured out that was because of mock-maker-inline property applied via org.mockito.plugins.MockMaker file.

答:
Can you please suggest how to implement such I believe very common scenario

As @JoeC wrote, this is not a common scenario.

The reason is: you test the behavior of Mockito, but you should test your codes behavior instead.

In order to do so you instantiate your code under test without mocking it and pass in mocks for its dependencies.

Body:
let's assume I have this simple scenario.

package kivoxdaemon.utils;

import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;

public class TempTest {

   @Test
   public void test() {

      TestMock testMock = Mockito.mock(TestMock.class);

      Mockito.doCallRealMethod().when(testMock).method1();

      Mockito.doAnswer(new Answer() {
         @Override
         public Object answer(InvocationOnMock invocation) throws Throwable {
            System.out.println("Mock method3");
            return null;
         }
      }).when(testMock).method3();

      testMock.method1();
   }

}

class TestMock {

   void method1() {
      System.out.println("method1");
      method2();
   }

   private void method2() {
      System.out.println("method2");
      method3();
   }

   void method3() {
      System.out.println("method3");
   }
}

This code has the following output in console:

method1

method2

method3

whereas I would expect it to be

method1

method2

Mock method3

Method 3 is mocked, so why isn't it getting called?

Can you please suggest how to implement such I believe very common scenario, when the call chain starts from a real public method, but some other methods, called internally, have to be mocked?

Thank you in advance.

UPD: Just figured out that was because of mock-maker-inline property applied via org.mockito.plugins.MockMaker file.


问:
Do Azure virtual networks allow public addressing to sources in the VPN domain after connecting to the peer or Azure virtual network gateway
We have a client that does not support NAT or RFC1918 addressing within VPN tunnels (encryption domain) and/or Peers.

The Azure virtual network gateways setup without a load balancer appear to not do NAT unless you have a load balancer out front which is good, correct me if I am wrong.

But can internal virtual machines in the virtual network at Azure have public ips only? Or does Azure require private virtual network addressing but you can also associate the public IP?  We have set it up with the gateway public ip, virtual network with a 10.x.x.x subnet and associated public IPs to the sources or virtual machines.

Can virtual network machines only have a public IP at Azure? Or can you reach instances by public IP when connected to the Azure virtual network public IP even with private addressing in addition to the public IP binding?

答:
But can internal virtual machines in the virtual network at Azure have
  public ips only? Or does Azure require private virtual network
  addressing but you can also associate the public IP?

Every Azure VM create by a private IP address, then we can associate a public IP address to it.

Or can you reach instances by public IP when connected to the Azure
  virtual network public IP even with private addressing in addition to
  the public IP binding?

Yes, we can connect that VM with public IP address directly.


问:
Notifying child components which is active one
Is there a better way to do the following? The following is spinning the CPU in Chrome (as per Javascript profiler).

```<code><div *ngFor="let item of items">
    <itemComp [item]="item" [active]="item == service.activeItem"></itemComp>
</div>
</code>```

Is there a way for each of the itemComp components to subscribe for a notification when they become active?

For ex., once they are rendered, let's say the user clicks on any of the items to mark as active. Only one item can be active any time. and say, I want to just change the background color of the active item to highlight it. In this case the current active item becomes inactive and a new item becomes active. How do I propagate this change?

答:
There are multiple ways to do it but I find subjects to be the most clean somehow.

Parent:

```<code>export const someEvent: Subject<Something> = new Subject<Something>();

export class someParentClass{

   public somethingHappened() {
      someEvent.next("something");
   }

}
</code>```

In the child:

```<code>import { Subscription } from 'rxjs/Subscription';
import { someEvent } from './someParentClass';

export class SomeChildClass implements OnInit, OnDestroy{

    public someSubscription: Subscription;

    public ngOnInit(){
       this.someSubscription = someEvent.subscribe((something) => {
              console.log("something happened" ,something);
       });
    }

    public ngOnDestroy(){
       // if you don't do this then you'll have events firing off in components
       // that don't exist anymore
       this.someSubscription.unsubscribe();
    }

}
</code>```

Just a small note about subjects vs event emitters.
The thing about event emitters is it something that is created specifically for child/parent communication in @Output form. Subject hasn't got this "restriction" (performance issues) and thus can be used more widely even in services or repositories that are around your application. To boost there are many variations to subjects, such as async and behavior subject that all have small quirks that will fit a certain situation.

If you are using an @Output do use eventemitter, otherwise subject.

Body:
Is there a better way to do the following? The following is spinning the CPU in Chrome (as per Javascript profiler).

    <itemComp [item]="item" [active]="item == service.activeItem"></itemComp>

Is there a way for each of the itemComp components to subscribe for a notification when they become active?

For ex., once they are rendered, let's say the user clicks on any of the items to mark as active. Only one item can be active any time. and say, I want to just change the background color of the active item to highlight it. In this case the current active item becomes inactive and a new item becomes active. How do I propagate this change?

Body:
There are multiple ways to do it but I find subjects to be the most clean somehow.

Parent:

export const someEvent: Subject<Something> = new Subject<Something>();

export class someParentClass{

   public somethingHappened() {
      someEvent.next("something");
   }

}

In the child:

import { Subscription } from 'rxjs/Subscription';
import { someEvent } from './someParentClass';

export class SomeChildClass implements OnInit, OnDestroy{

    public someSubscription: Subscription;

    public ngOnInit(){
       this.someSubscription = someEvent.subscribe((something) => {
              console.log("something happened" ,something);
       });
    }

    public ngOnDestroy(){
       // if you don't do this then you'll have events firing off in components
       // that don't exist anymore
       this.someSubscription.unsubscribe();
    }

}

Just a small note about subjects vs event emitters.
The thing about event emitters is it something that is created specifically for child/parent communication in @Output form. Subject hasn't got this "restriction" (performance issues) and thus can be used more widely even in services or repositories that are around your application. To boost there are many variations to subjects, such as async and behavior subject that all have small quirks that will fit a certain situation.

If you are using an @Output do use eventemitter, otherwise subject.


问:
unable to plot graph matplotlib in jupyter notebook
im using a new laptop and transfer my old data to the new one. however my matplotlib doesnt want to plot the graph in the new window but it works in the old one. i have check the installation of matplotlib and everything and no idea what is going wrong

```<code>import numpy as np
import matplotlib.pyplot as pl

#creating list
pd = {0.05, 0.34, 0.56, 0.5, 0.7,0.2, 0.36, 0.54, 0.65, 0.456}
#len of the lists
d = len (pd)
print (d)

x = range(d)
bwidth= 1/1.25
pl.figure(1,figsize =(7,5))
pl.bar(x,pd,bwidth, color = "red")
pl.show()
</code>```

and this is the error that i got

```<code>TypeError                                 Traceback (most recent call last)
<ipython-input-12-b7b3df1db861> in <module>()
     12 bwidth= 1/1.25
     13 pl.figure(1,figsize =(7,5))
---> 14 pl.bar(x,pd,bwidth, color = "red")
     15 pl.show()

 C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\pyplot.py in
 bar(*args, **kwargs)
 2625                       mplDeprecation)
 2626     try:
->2627         ret = ax.bar(*args, **kwargs)
 2628     finally:
 2629         ax._hold = washold

 C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\__init__.py in
 inner(ax, *args, **kwargs)
  1708                     warnings.warn(msg % (label_namer, func.__name__),
  1709                                   RuntimeWarning, stacklevel=2)
->1710             return func(ax, *args, **kwargs)
  1711         pre_doc = inner.__doc__
  1712         if pre_doc is None:

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_axes.py in
bar(self, *args, **kwargs)
   2154             elif orientation == 'horizontal':
   2155                 r.sticky_edges.x.append(l)
-> 2156             self.add_patch(r)
   2157             patches.append(r)
   2158

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_base.py in
add_patch(self, p)
   1832         if p.get_clip_path() is None:
   1833             p.set_clip_path(self.patch)
-> 1834         self._update_patch_limits(p)
   1835         self.patches.append(p)
   1836         p._remove_method = lambda h: self.patches.remove(h)

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_base.py in
_update_patch_limits(self, patch)
   1852         vertices = patch.get_path().vertices
   1853         if vertices.size > 0:
-> 1854             xys = patch.get_patch_transform().transform(vertices)
   1855             if patch.get_data_transform() != self.transData:
   1856                 patch_to_data = (patch.get_data_transform() -

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\patches.py in
get_patch_transform(self)
    720
    721     def get_patch_transform(self):
--> 722         self._update_patch_transform()
    723         return self._rect_transform
    724

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\patches.py in
_update_patch_transform(self)
    713         width = self.convert_xunits(self._width)
    714         height = self.convert_yunits(self._height)
--> 715         bbox = transforms.Bbox.from_bounds(x, y, width, height)
    716         rot_trans = transforms.Affine2D()
    717         rot_trans.rotate_deg_around(x, y, self.angle)

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\transforms.py in
from_bounds(x0, y0, width, height)
    802         *width* and *height* may be negative.
    803         """
--> 804         return Bbox.from_extents(x0, y0, x0 + width, y0 + height)
    805
    806     @staticmethod

TypeError: unsupported operand type(s) for +: 'int' and 'set'
</code>```

im using matplotlib 2.1.0 version and Python 3.6.3

答:
You cannot plot sets. In the code above pd is a set, not a list.

You can convert to a list first before plotting,

```<code>plt.bar(x, list(pd), bwidth, color = "red")
</code>```

Body:
im using a new laptop and transfer my old data to the new one. however my matplotlib doesnt want to plot the graph in the new window but it works in the old one. i have check the installation of matplotlib and everything and no idea what is going wrong

import numpy as np
import matplotlib.pyplot as pl

#creating list
pd = {0.05, 0.34, 0.56, 0.5, 0.7,0.2, 0.36, 0.54, 0.65, 0.456}
#len of the lists
d = len (pd)
print (d)

x = range(d)
bwidth= 1/1.25
pl.figure(1,figsize =(7,5))
pl.bar(x,pd,bwidth, color = "red")
pl.show()

and this is the error that i got

TypeError                                 Traceback (most recent call last)
<ipython-input-12-b7b3df1db861> in <module>()
     12 bwidth= 1/1.25
     13 pl.figure(1,figsize =(7,5))
---> 14 pl.bar(x,pd,bwidth, color = "red")
     15 pl.show()

 C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\pyplot.py in
 bar(*args, **kwargs)
 2625                       mplDeprecation)
 2626     try:
->2627         ret = ax.bar(*args, **kwargs)
 2628     finally:
 2629         ax._hold = washold

 C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\__init__.py in
 inner(ax, *args, **kwargs)
  1708                     warnings.warn(msg % (label_namer, func.__name__),
  1709                                   RuntimeWarning, stacklevel=2)
->1710             return func(ax, *args, **kwargs)
  1711         pre_doc = inner.__doc__
  1712         if pre_doc is None:

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_axes.py in
bar(self, *args, **kwargs)
   2154             elif orientation == 'horizontal':
   2155                 r.sticky_edges.x.append(l)
-> 2156             self.add_patch(r)
   2157             patches.append(r)
   2158

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_base.py in
add_patch(self, p)
   1832         if p.get_clip_path() is None:
   1833             p.set_clip_path(self.patch)
-> 1834         self._update_patch_limits(p)
   1835         self.patches.append(p)
   1836         p._remove_method = lambda h: self.patches.remove(h)

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_base.py in
_update_patch_limits(self, patch)
   1852         vertices = patch.get_path().vertices
   1853         if vertices.size > 0:
-> 1854             xys = patch.get_patch_transform().transform(vertices)
   1855             if patch.get_data_transform() != self.transData:
   1856                 patch_to_data = (patch.get_data_transform() -

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\patches.py in
get_patch_transform(self)
    720
    721     def get_patch_transform(self):
--> 722         self._update_patch_transform()
    723         return self._rect_transform
    724

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\patches.py in
_update_patch_transform(self)
    713         width = self.convert_xunits(self._width)
    714         height = self.convert_yunits(self._height)
--> 715         bbox = transforms.Bbox.from_bounds(x, y, width, height)
    716         rot_trans = transforms.Affine2D()
    717         rot_trans.rotate_deg_around(x, y, self.angle)

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\transforms.py in
from_bounds(x0, y0, width, height)
    802         *width* and *height* may be negative.
    803         """
--> 804         return Bbox.from_extents(x0, y0, x0 + width, y0 + height)
    805
    806     @staticmethod

TypeError: unsupported operand type(s) for +: 'int' and 'set'

im using matplotlib 2.1.0 version and Python 3.6.3

Body:
You cannot plot sets. In the code above pd is a set, not a list.

You can convert to a list first before plotting,

plt.bar(x, list(pd), bwidth, color = "red")


问:
Repeating a value when a previous variable value has occured
I have a data set with the following variables:
1. Group
2. Status (Takes on variables 1-7)

I need to create a flag where the following conditions are met:
-Flag 1=0 when Status <6, else Flag 1= 1 when Status >=6
-Within each group: If Status has reached 6 or higher and goes back down to below 6, the flag 1 must remain as 1.

The desired table would look as follows:

答:
Using ave to apply a custom function within each group.

```<code>df <- data.frame(Group = c(1,2,2,3,3,3,3,4,4),
                 Status = c(1,2,3,7,6,5,4,5,6))

df$Flag = ave(df$Status, df$Group, FUN = function(x) {cumsum(x >= 6) > 0})
</code>```

Body:
Using ave to apply a custom function within each group.

df <- data.frame(Group = c(1,2,2,3,3,3,3,4,4),
                 Status = c(1,2,3,7,6,5,4,5,6))

df$Flag = ave(df$Status, df$Group, FUN = function(x) {cumsum(x >= 6) > 0})


问:
tkinter, button returns variable
I am trying to make a GUI text based adventure game in python. I want to be able to take text from a textinput box and store it as string variable.

I have 2 problems:

Making the python wait for the submit button to be pressed, before
processing the input and updating the game.

Getting the text variable out of the command, I would like to not
use global if possible.

Here is some of my code to better understand:

```<code>root = tk.Tk()
root.geometry('800x600+100+100')
root.title("my game")
textbox = tk.StringVar()
textboxentry = tk.Entry(root, textvariable=textbox, bd=5, width = "40",  font=("times", 20))
textboxentry.pack(in_=bgImageLabel, side = "bottom")
def getInput():
    textboxInput = textbox.get() #gets entry
    lengthEntry = len(textbox.get())
    textboxentry.delete(0,lengthEntry) #removes entry from widget
    return textboxInput # I would like this return to work

submit = tk.Button(root, text ="Submit", command = (textboxInput = getInput()))
##I want the command function to use command = getInput and store the return on getInput as textboxInput. This will update the wait_variable down below, and give the inputs(textboxInput) a string to work with.

submit.pack(in_=bgImageLabel, side = "bottom")

while game == True:
    root.update_idletasks()
    root.update()
    submit.wait_variable(textboxentry)
## I need it to wait before proceeding to this next line because i need the textboxInput from the entry widget.
    actionInput, extraInput, texts = inputs(textboxInput)
</code>```

Currently I can't figure a way to use command = (textboxInput = getInput), using lambda or anything else. I just want to store the return which comes off of the Entry as a string variable that can be used by the main function.
All help is appreciated!

答:
Below code processes entry widget's text when Submit button is pressed.

```<code>import tkinter as tk

root = tk.Tk()

aVarOutside = 'asd'
def btn_cmd(obj):

    #use global variable
    global aVarOutside
    #print its unmodified value
    print("aVarOutside: " + aVarOutside)
    #modify it with what's written in Entry widget
    aVarOutside = obj.get()

    #modify lblTextVar, which is essentially modifying Label's text as lblTextVar is its textvariable
    lblTextVar.set(obj.get())

    #print what's inside Entry
    print("Entry: " + obj.get())

txt = tk.Entry(root)
txt.pack()

lblTextVar = tk.StringVar()
lbl = tk.Label(root, textvariable=lblTextVar)
lbl.pack()

btn = tk.Button(text="Submit", command=lambda obj = txt : btn_cmd(obj))
btn.pack()

root.mainloop()
</code>```

When the button is pressed:

Value of a global variable, aVarOutside is printed.

Value of aVarOutside is modified to the value of Entry box's
(txt's) content.

Value of a textvariable used by a label (lbl) is modified. Which
means that the text of lbl is updated and can be seen on the GUI.

Finally Entry box, txt's content is printed.

Title: tkinter, button returns variable

Body:
I am trying to make a GUI text based adventure game in python. I want to be able to take text from a textinput box and store it as string variable.

I have 2 problems:

Making the python wait for the submit button to be pressed, before
processing the input and updating the game.

Getting the text variable out of the command, I would like to not
use global if possible.

Here is some of my code to better understand:

root = tk.Tk()
root.geometry('800x600+100+100')
root.title("my game")
textbox = tk.StringVar()
textboxentry = tk.Entry(root, textvariable=textbox, bd=5, width = "40",  font=("times", 20))
textboxentry.pack(in_=bgImageLabel, side = "bottom")
def getInput():
    textboxInput = textbox.get() #gets entry
    lengthEntry = len(textbox.get())
    textboxentry.delete(0,lengthEntry) #removes entry from widget
    return textboxInput # I would like this return to work

submit = tk.Button(root, text ="Submit", command = (textboxInput = getInput()))
##I want the command function to use command = getInput and store the return on getInput as textboxInput. This will update the wait_variable down below, and give the inputs(textboxInput) a string to work with.

submit.pack(in_=bgImageLabel, side = "bottom")

while game == True:
    root.update_idletasks()
    root.update()
    submit.wait_variable(textboxentry)
## I need it to wait before proceeding to this next line because i need the textboxInput from the entry widget.
    actionInput, extraInput, texts = inputs(textboxInput)

Currently I can't figure a way to use command = (textboxInput = getInput), using lambda or anything else. I just want to store the return which comes off of the Entry as a string variable that can be used by the main function.
All help is appreciated!

Body:
Below code processes entry widget's text when Submit button is pressed.

import tkinter as tk

root = tk.Tk()

aVarOutside = 'asd'
def btn_cmd(obj):

    #use global variable
    global aVarOutside
    #print its unmodified value
    print("aVarOutside: " + aVarOutside)
    #modify it with what's written in Entry widget
    aVarOutside = obj.get()

    #modify lblTextVar, which is essentially modifying Label's text as lblTextVar is its textvariable
    lblTextVar.set(obj.get())

    #print what's inside Entry
    print("Entry: " + obj.get())

txt = tk.Entry(root)
txt.pack()

lblTextVar = tk.StringVar()
lbl = tk.Label(root, textvariable=lblTextVar)
lbl.pack()

btn = tk.Button(text="Submit", command=lambda obj = txt : btn_cmd(obj))
btn.pack()

root.mainloop()

When the button is pressed:

Value of a global variable, aVarOutside is printed.

Value of aVarOutside is modified to the value of Entry box's
(txt's) content.

Value of a textvariable used by a label (lbl) is modified. Which
means that the text of lbl is updated and can be seen on the GUI.

Finally Entry box, txt's content is printed.


问:
Use custom intent action to launch activity only in specific application context
I need to specify my login activity with intent filter:

```<code>    <activity
        android:name=".view.LoginActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="com.example.sdk.LOGIN" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
</code>```

The reason why I want to do it that way is that I am developing an SDK that I want to use in few projects and this is the best way I could figure out of how to notify the SDK which is the login activity, while it is defined only in the app module.

After I do such declaration I start the login activity like so (both in library and app):

```<code>    Intent intent = new Intent();
    intent.setAction("com.example.sdk.LOGIN");
    context.startActivity(intent);
</code>```

There is the possibility that two or more applications relying on the same SDK will be installed simultaneously on the same device. If I get it correctly, in such case in each of these applications the Activity start will launch a random login activity (with the possibility of the call in application A launching the login of application B).

Am I correct in my understanding of how custom intent filters work?

Is there a way to tell the call in application A to use only intent filter declarations in application A

Suggestions of alternative approaches to reusing the login-related logic, not relying on intent filters are also welcome.

答:
In such case in each of these applications the Activity start will launch a random login activity.

That's not quite true. From docs:

If there's only one app that can handle it, that app opens immediately and is given the intent. If multiple activities accept the intent, the system displays a dialog, so the user can pick which app to use.

As to your second question:

Is there a way to tell the call in application A to use only intent filter declarations in application A?

I assume you are unable to launch the activity using explicit intents, because you cannot know the activity name of your client within the library module.

There is no API, that would give you activity class, filtered by its intent-filter property. PackageManager API cannot come in help. That means, you cannot get the class instance of the activity in order to explicitly start the activity. That in turn means, that the only way for you is to start the activity implicitly, which, as already said, will prompt with dialog.

Body:
I need to specify my login activity with intent filter:

    <activity
        android:name=".view.LoginActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="com.example.sdk.LOGIN" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

The reason why I want to do it that way is that I am developing an SDK that I want to use in few projects and this is the best way I could figure out of how to notify the SDK which is the login activity, while it is defined only in the app module.

After I do such declaration I start the login activity like so (both in library and app):

    Intent intent = new Intent();
    intent.setAction("com.example.sdk.LOGIN");
    context.startActivity(intent);

There is the possibility that two or more applications relying on the same SDK will be installed simultaneously on the same device. If I get it correctly, in such case in each of these applications the Activity start will launch a random login activity (with the possibility of the call in application A launching the login of application B).

Am I correct in my understanding of how custom intent filters work?

Is there a way to tell the call in application A to use only intent filter declarations in application A

Suggestions of alternative approaches to reusing the login-related logic, not relying on intent filters are also welcome.


问:
What is the difference between collapsible and accordion in bootstrap?
What is the difference between collapsible and accordion in bootstrap?

sample Code collapsible:

```<code>    <div class="panel-heading">
  <h4 class="panel-title">
    <a data-toggle="collapse" href="#collapse1">Collapsible panel</a>
  </h4>
</div>
<div id="collapse1" class="panel-collapse collapse">
  <div class="panel-body">Panel Body</div>
  <div class="panel-footer">Panel Footer</div>
</div>
</code>```

sample code for accordion

```<code>      <h4 class="panel-title">
    <a data-toggle="collapse" data-parent="#accordion" href="#collapse1">
    Collapsible Group 1</a>
  </h4>
</div>
<div id="collapse1" class="panel-collapse collapse in">
  <div class="panel-body">Hello World</div>
</div>
</code>```

答:
According to Bootstrap 4 Collapse, " Accordion Toggle the visibility of content across your project with a few classes and our JavaScript plugins." [1]

Accordion are useful when you want to toggle between hiding and showing large amount of content. [2]

In bootstrap context wise, accordion is basically a collapse button with a lot of smaller info in it. Bootstrap use card to make an accordion.

A snippet from Bootstrap 4

```<code><div id="accordion" role="tablist">
  <div class="card">
    <div class="card-header" role="tab" id="headingOne">
      <h5 class="mb-0">
        <a data-toggle="collapse" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
          Collapsible Group Item #1
        </a>
      </h5>
    </div>

    <div id="collapseOne" class="collapse show" role="tabpanel" aria-labelledby="headingOne" data-parent="#accordion">
      <div class="card-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
  <div class="card">
    <div class="card-header" role="tab" id="headingTwo">
      <h5 class="mb-0">
        <a class="collapsed" data-toggle="collapse" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
          Collapsible Group Item #2
        </a>
      </h5>
    </div>
    <div id="collapseTwo" class="collapse" role="tabpanel" aria-labelledby="headingTwo" data-parent="#accordion">
      <div class="card-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
  <div class="card">
    <div class="card-header" role="tab" id="headingThree">
      <h5 class="mb-0">
        <a class="collapsed" data-toggle="collapse" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
          Collapsible Group Item #3
        </a>
      </h5>
    </div>
    <div id="collapseThree" class="collapse" role="tabpanel" aria-labelledby="headingThree" data-parent="#accordion">
      <div class="card-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
</div>
</code>```

on line 1,
, this is where the data-parent refers to.

on line 2
, we are using a card class, to show the card effect.

```<code><div class="card-header" role="tab" id="headingOne">
      <h5 class="mb-0">
        <a data-toggle="collapse" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
</code>```

this 3 lines is just stating a new id headingOne, and then in the a tag, data-toggle="collapse" aria-expanded="true" is required for the effect of collapse, and the target is with id collapseOne.

Once you press that a tag,

```<code><div id="collapseOne" class="collapse show" role="tabpanel" aria-labelledby="headingOne" data-parent="#accordion">
      <div class="card-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
</code>```

 this line is self explainable, data-parent refer back to the id #accordion, labelledby="headingOne" and the role (tablist -the container of the tab, tab- the pressable button to toggle the panel, tabpanel- the content that are initially close, triggered by tab)

For more details, just read the official Bootstrap collpase

Source:

https://getbootstrap.com/docs/4.0/components/collapse

https://www.w3schools.com/howto/howto_js_accordion.asp

Body:
What is the difference between collapsible and accordion in bootstrap?

sample Code collapsible:

    Collapsible panel

Panel Body

Panel Footer

sample code for accordion

    Collapsible Group 1

Hello World

Body:
According to Bootstrap 4 Collapse, " Accordion Toggle the visibility of content across your project with a few classes and our JavaScript plugins." [1]

Accordion are useful when you want to toggle between hiding and showing large amount of content. [2]

In bootstrap context wise, accordion is basically a collapse button with a lot of smaller info in it. Bootstrap use card to make an accordion.

A snippet from Bootstrap 4

<div id="accordion" role="tablist">
  <div class="card">
    <div class="card-header" role="tab" id="headingOne">
      <h5 class="mb-0">
        <a data-toggle="collapse" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
          Collapsible Group Item #1
        </a>
      </h5>
    </div>

    <div id="collapseOne" class="collapse show" role="tabpanel" aria-labelledby="headingOne" data-parent="#accordion">
      <div class="card-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
  <div class="card">
    <div class="card-header" role="tab" id="headingTwo">
      <h5 class="mb-0">
        <a class="collapsed" data-toggle="collapse" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
          Collapsible Group Item #2
        </a>
      </h5>
    </div>
    <div id="collapseTwo" class="collapse" role="tabpanel" aria-labelledby="headingTwo" data-parent="#accordion">
      <div class="card-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
  <div class="card">
    <div class="card-header" role="tab" id="headingThree">
      <h5 class="mb-0">
        <a class="collapsed" data-toggle="collapse" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
          Collapsible Group Item #3
        </a>
      </h5>
    </div>
    <div id="collapseThree" class="collapse" role="tabpanel" aria-labelledby="headingThree" data-parent="#accordion">
      <div class="card-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
</div>

on line 1, <div id="accordion" role="tablist">, this is where the data-parent refers to.

on line 2 <div class="card">, we are using a card class, to show the card effect.

<div class="card-header" role="tab" id="headingOne">
      <h5 class="mb-0">
        <a data-toggle="collapse" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">

this 3 lines is just stating a new id headingOne, and then in the a tag, data-toggle="collapse" aria-expanded="true" is required for the effect of collapse, and the target is with id collapseOne.

Once you press that a tag,

<div id="collapseOne" class="collapse show" role="tabpanel" aria-labelledby="headingOne" data-parent="#accordion">
      <div class="card-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>

<div id="collapseOne" class="collapse show" role="tabpanel" aria-labelledby="headingOne" data-parent="#accordion">
 this line is self explainable, data-parent refer back to the id #accordion, labelledby="headingOne" and the role (tablist -the container of the tab, tab- the pressable button to toggle the panel, tabpanel- the content that are initially close, triggered by tab)

For more details, just read the official Bootstrap collpase

Source:

https://getbootstrap.com/docs/4.0/components/collapse

https://www.w3schools.com/howto/howto_js_accordion.asp


问:
Navigation Drawer disable backview when drawer open
I am getting a strage behaviour with my navigation drawer. I use a custom layout for it, containing not only the usual listview!

Whenever i click somehwere in the drawer section the rows from the behind listview are getting clicked. How can i disable that?

SOLUTION:
just set android:clickable="true" on the parent layout in the drawer outside the listview and it all works fine.

Thanks for your answers.

答: Set android:clickable="true" to the parent layout in the drawer section.</p>