Spring Java Config vs Jboss 7

I was using @SpringBootApplication

As I read in this thread I needed to:

Change the mapping of the DispatcherServlet to “/*” instead of “https://stackoverflow.com/” (by adding a @Bean of type ServletRegistrationBean with a servlet named “dispatcherServlet”)

In this url I found the code solution: Add Servlet Mapping to dispatch servlet

@SpringBootApplication
public class Application extends SpringBootServletInitializer {

    @Bean
    public DispatcherServlet dispatcherServlet() {
        return new DispatcherServlet();
    }

    /**
     * Register dispatcherServlet programmatically 
     * 
     * @return ServletRegistrationBean
     */
    @Bean
    public ServletRegistrationBean dispatcherServletRegistration() {
        ServletRegistrationBean registration = new ServletRegistrationBean(
                dispatcherServlet(), "/*");
        registration
                .setName(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
        return registration;
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

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

}

Leave a Comment