3

I try to make spring boot to load stuff from web.xml and so far it is ignoring definitions from there...

I have bellow starter:

@Configuration
@EnableAutoConfiguration
@ComponentScan
@SpringBootApplication
@ImportResource(value = {"classpath:/*-beans.xml"})
public class Application extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }
    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class, args);
    }
}

I see in logs that spring beans are initialized but no definitions are loaded from web.xml...

Jhon
  • 433
  • 4
  • 19
  • and it never will... Just add those things to your `Application` class. – M. Deinum Jun 18 '15 at 08:40
  • Basically the `SpringBootServletInitializer` is the replacement for the `web.xml`. In servlet 3.0 you don't need a web.xml. Next to that if you are running the main method it will start an embedded server which also ignores the web.xml. – M. Deinum Jun 18 '15 at 08:53
  • Possible duplicate of [Configuring a spring-boot application using web.xml](https://stackoverflow.com/questions/19053388/configuring-a-spring-boot-application-using-web-xml) – Alex R Mar 29 '19 at 05:09
  • @M.Deinum According to https://www.baeldung.com/custom-error-page-spring-mvc the web.xml is mandatory in that use-case... – slartidan May 14 '19 at 10:55
  • That is for Plain spring applications NOT Spring Boot applications. – M. Deinum May 14 '19 at 10:56

0 Answers0